On Thursday, April 12, 2018 at 4:02:32 PM UTC+3, [email protected] wrote: > > Im currently trying to make transactions from a p2sh Wallet. > I ran the TransactionInput.verify() and it didnt throw any exceptions. > When i try to run the completeTx() method on the SendRequest it thorws a > NullPointerException. > When i debugged the code execution i discovered that the > Wallet.findRedeemDataFromScriptHash() returns null. > > Why does this method returns null and what is its purpose how can i fix or > get around this problem? > > Here is the code, thanks for the help: > > Transaction clientTx = new Transaction(params); > clientTx.addOutput(value, testWallet.wallet().getWatchingKey()); > TransactionInput input = clientTx.addInput(multisigOutput); > Sha256Hash sighashClient = clientTx.hashForSignature(0, redeem, > Transaction.SigHash.ALL, false); > ECKey.ECDSASignature mySignature = > client.wallet().getWatchingKey().sign(sighashClient); > > TransactionSignature clientTxSig = new > TransactionSignature(mySignature, Transaction.SigHash.ALL, false); > TransactionSignature serverTxSig = new > TransactionSignature(signature, Transaction.SigHash.ALL, false); > > Script inputScript = > ScriptBuilder.createP2SHMultiSigInputScript(ImmutableList.of(serverTxSig, > clientTxSig),redeem); > > > byte[] sigHashByte = sighashClient.getBytes(); > byte[] clientWatchingKey = > client.wallet().getWatchingKey().getPubKey(); > byte[] serverWatchingKey = > server.wallet().getWatchingKey().getPubKey(); > > > System.out.println(ECKey.verify(sigHashByte,mySignature,clientWatchingKey)); > > System.out.println(ECKey.verify(sigHashByte,signature,serverWatchingKey)); > > input.setScriptSig(inputScript); > input.verify(multisigOutput); > > > BlockChain chain = multisig.chain(); > BlockStore bs = chain.getBlockStore(); > Peer peer = multisig.peerGroup().getDownloadPeer(); > Block b = > peer.getBlock(bs.getChainHead().getHeader().getHash()).get(); > > // System.out.println(testWallet.wallet().getTransactions(true)); > SendRequest request = SendRequest.forTx(clientTx); > PeerGroup peerGroup = multisig.peerGroup(); > peerGroup.setMinBroadcastConnections(2); > System.out.println(clientTx.getOutput(0)); > multisig.wallet().completeTx(request); > > > > And here is the exception: > > > Exception in thread "main" java.lang.NullPointerException > at > org.bitcoinj.wallet.DecryptingKeyBag.maybeDecrypt(DecryptingKeyBag.java:58) > at > org.bitcoinj.wallet.DecryptingKeyBag.findRedeemDataFromScriptHash(DecryptingKeyBag.java:79) > at > org.bitcoinj.core.TransactionOutPoint.getConnectedRedeemData(TransactionOutPoint.java:175) > at > org.bitcoinj.core.TransactionInput.getConnectedRedeemData(TransactionInput.java:298) > at org.bitcoinj.wallet.Wallet.signTransaction(Wallet.java:4061) > at org.bitcoinj.wallet.Wallet.completeTx(Wallet.java:3998) > at kesem.sdk.Testing.BitcoinJ.createP2SHAccount(BitcoinJ.java:166) > at kesem.sdk.Testing.BitcoinJ.main(BitcoinJ.java:252) > > >
-- You received this message because you are subscribed to the Google Groups "bitcoinj" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
