Back to Blog
blockchain
4 min read

Broadcasting transaction with multiple recipients using BDK-Kotlin

A quick guide on how to use the BDK-Kotlin 0.7.0 library to create a send transaction with multiple recipients.

Tang Yetong
Tang Yetong
Full Stack Developer and former Data Analyst Intern at Fivetran with a background in government digital services and blockchain technology.

A quick guide on how to use the BDK-Kotlin 0.7.0 library to create a send transaction with multiple recipients. You can use the Padawan Wallet and dev-kit open-source projects as reference.

TxBuilder

With the TxBuilder() you can create the transaciton as per usual.

var txBuilder = TxBuilder() for (recipient in recipientList) { txBuilder = txBuilder.addRecipient(address = recipient.first, amount = recipient.second) } txBuilder = txBuilder.feeRate(satPerVbyte = feeRate) return txBuilder.finish(wallet)

You can write this piece of logic however you want, but to give an example of using scopes to read the recipientList data :

val psbt = recipientList.fold(TxBuilder()) { builder, recipient -> builder.addRecipient(recipient.address, recipient.amount) }.finish(wallet)

Sign & Broadcast

After you have the PSBT object you can do whatever you want with it! Sign and broadcast with the Wallet and Blockchain object to send out the transaction.

Tags

BDK-Kotlin
Bitcoin
Transactions
Multiple Recipients
Tang Yetong

Tang Yetong

Full Stack Developer and former Data Analyst Intern at Fivetran with a background in government digital services and blockchain technology.

Related Articles

Featured
5 mins

How to contribute to Padawan Wallet

blockchain

A quick summary of what the Padawan Wallet is, why it exists and how you can contribute to it!

Bitcoin
Open Source
BDK-Kotlin
+1
Read Article: How to contribute to Padawan Wallet
Featured
8 mins

Summer of Bitcoin 2022

blockchain

This is the last week of the Summer of Bitcoin (SoB) 2022 internship and what a journey it has been.

SoB
Internship
Bitcoin
+1
Read Article: Summer of Bitcoin 2022
4 mins

Bumping RBF Enabled Transaction Fees using BDK-Kotlin

blockchain

A quick guide on how to use the BDK-Kotlin 0.8.0 library to bump Replace-By-Fee(RBF) enabled transaction fees.

BDK-Kotlin
Bitcoin
RBF
+1
Read Article: Bumping RBF Enabled Transaction Fees using BDK-Kotlin