Bitcoin
A$ 88,087
WINkLink
A$ 0.0008691
Ethereum
A$ 5,505.1

How to make transaction with many inputs and one output in BitcoinJ?

I’m trying to send all coins from my accounts (generated by HD Wallet) to one account with this code:

fun sendAllFundsOnAddress(address: String) {
        val receiver = Address.fromString(params, address)
        val tx = Transaction(params)

        val balance = Coin.valueOf(walletAppKit.wallet().unspents.map { it.value.value }.sum())
        tx.addOutput(balance, receiver)

        walletAppKit.wallet().unspents.forEach {
            val key = walletAppKit.wallet().findKeyFromAddress(Address.fromString(params, it.scriptPubKey.getToAddress(params).toString()))
            tx.addSignedInput(it.outPointFor, it.scriptPubKey, key, Transaction.SigHash.ALL, true)
        }

        walletAppKit.wallet().commitTx(tx)
        val sendRequest = SendRequest.forTx(tx)
        walletAppKit.wallet().completeTx(sendRequest)
    }

But I get NullPointerException, while it calculates witness (in input signing process).

Could you give any ideas, what’s wrong?

Related Posts

Leave a Reply

Subscribe To Newsletter

For updates and exclusive offers, enter your e-mail below.

Donate To Cryptonic Australia


Donate BTC: 1MPYuHUKm3AhNivMSngqLnoEbpNEecHeEK
Donate Doge: DDYybw7H8zx8EYU74JrGW8WwmYh9AGuyMC
Donate WinK: TDiXutqKE3P17LpZMQh3SDBCGSkAC6iEjB




LUNA Outperforms Bitcoin’s Rally, Why It’s Ready For Massive Gains
October 20, 2021
Recoverybitcoins
October 20, 2021
Medical Firm In Mexico To Introduce COVID-19 Testing Through Blockchain
October 20, 2021




LUNA Outperforms Bitcoin’s Rally, Why It’s Ready For Massive Gains
October 20, 2021
Recoverybitcoins
October 20, 2021
Medical Firm In Mexico To Introduce COVID-19 Testing Through Blockchain
October 20, 2021


CryptoCurrencyAUDChange 1hChange 24hChange 7d
Bitcoin88,087 0.04 % 3.20 % 17.56 %
Ethereum5,505.1 0.01 % 7.83 % 18.32 %
Binance Coin670.68 0.06 % 3.61 % 14.50 %
Cardano2.920 0.27 % 4.05 % 3.48 %
Tether1.340 0.09 % 0.52 % 0.32 %
XRP1.520 0.45 % 5.31 % 3.72 %
Solana230.63 0.69 % 11.25 % 14.06 %
Polkadot59.12 0.52 % 7.58 % 26.51 %
Dogecoin0.3417 0.12 % 4.65 % 13.51 %
USD Coin1.340 0.03 % 0.37 % 0.32 %

Recent Comments

Allison wick

I was a victim of WDC Markets investment scam some months ago myself. It was...

Greatness

he is the best when it comes to recovery, he helped recover my funds without...

URL

... [Trackback] [...] There you will find 63491 more Infos: cryptonic.com.au/evaluation-suggests-bitcoin-robust-palms-are-shopping-for-this-dip/ [...]