bitcoin - bitcoinj Connect P2SH input transaction to the output transaction -


i have created p2sh address , send coins address https://www.blocktrail.com/tbtc/address/2n8xu6rnawssxtp2xpjstut2viwqopehr3r

next want send coins 2n8xu6rnawssxtp2xpjstut2viwqopehr3r address.

how prepare p2sh transaction , connect output script?

public static void sendfromp2sh(walletappkit kit, address destadd, coin coin) throws addressformatexception, insufficientmoneyexception, executionexception, interruptedexception {     transaction tx = new transaction(testnet3params.get());     tx.addoutput(coin, destadd); //prepare destination output       wallet.sendrequest req = wallet.sendrequest.fortx(tx);      //todo prepare p2sh input output //https://www.blocktrail.com/tbtc/address/2n8xu6rnawssxtp2xpjstut2viwqopehr3r     script script = p2shscript(kit); //2n8xu6rnawssxtp2xpjstut2viwqopehr3r     transactionoutput t = null;//... how connect p2sh input transaction output ?     tx.addinput(t);      kit.wallet().completetx(req);     kit.wallet().committx(req.tx);     kit.peergroup().broadcasttransaction(req.tx).get(); }      prepare script p2sh address  2n8xu6rnawssxtp2xpjstut2viwqopehr3r        public static script p2shscript(walletappkit kit) {             eckey pubclientkey = kit.wallet().getimportedkeys().get(0);             eckey pubserverkey = kit.wallet().getimportedkeys().get(1);             return scriptbuilder.createp2shoutputscript(1, immutablelist.of(pubclientkey, pubserverkey));         } 

thank you.

what following constructor?

public transactionoutput(networkparameters params, transaction parent, biginteger value, address to) 

inside code speculates on 'to' address check if multisig , creates output script appropriately.


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -