It looks you managed to send funds to a multisig address.
But you don't have a multisig wallet, ie you can not know if someone
else sends funds to that address nor spend the coins sent to that
address.
If you have more questions, please send some code, explain what
problem you have.
Oscar


On Mon, Jan 2, 2017 at 8:49 AM, Álvaro Castro-Castilla
<[email protected]> wrote:
> Thank you very much for your detailed response Oscar.
> I managed to build a contract using createMultiSigOutputScript and then
> broadcasting the transaction, as described in
> https://bitcoinj.github.io/working-with-contracts#creating-multi-signature-outputs
> . I guess the main difference is that what I did is just a single
> transaction contract that requires that all value stored in the transaction
> is released by the multisig parties, whereas the married wallets solution is
> an actual wallet where you can spend multiple times and receive funds. Is
> this correct?
>
> Thank you!
>
>
>
> On Sunday, January 1, 2017 at 11:55:38 PM UTC+1, Oscar Guindzberg wrote:
>>
>> This is what you need to do to create a wallet where you manage 1 key
>> and other parties manage the 2 other keys:
>>
>> NetworkParameters params = TestNet3Params.get();
>>
>> DeterministicKey followingKey1 =
>> DeterministicKey.deserializeB58("tpubSuppliedByThirdParty1", params);
>> DeterministicKey followingKey2 =
>> DeterministicKey.deserializeB58("tpubSuppliedByThirdParty2", params);
>>
>> MarriedKeyChain chain = MarriedKeyChain.builder()
>>          .random(new SecureRandom())
>>          .followingKeys(followingKey1, followingKey2)
>>          .threshold(2).build();
>> wallet.addAndActivateHDChain(chain);
>> wallet..freshReceiveAddress(); // Returns a p2sh address starting with "2"
>>
>>
>>
>> If you don't have a third party to provide the extended pubkeys yet,
>> you can generate them yourself (for testing purposes):
>>
>> DeterministicKeyChain keyChain1 = new DeterministicKeyChain(new
>> SecureRandom());
>> String tpubSuppliedByThirdParty1 =
>> keyChain.getWatchingKey().serializePubB58(params);
>>
>>
>> Once you have funds on your wallet, you can spend them by doing:
>>
>> // Generate a partially signed tx
>> Wallet.SendRequest req = Wallet.SendRequest.to(new Address(params,
>> "destinationAddress"), Coin.MILLICOIN);
>> req.missingSigsMode = Wallet.MissingSigsMode.USE_OP_ZERO;
>> wallet.completeTx(req);
>> Transaction tx = req.tx;
>>
>> // Send the tx to sign to the other party offilne. The other party
>> will give you:
>> byte[] signatureByThirdParty = ....
>> ECKey thirdPartyPubKey = ...
>>
>> // Then complete the partially signed tx
>> TransactionInput txIn = tx.getInputs().get(0); // This example assumes
>> just 1 input
>> Script inputScript = txIn.getScriptSig();
>> List<ScriptChunk> chunks = inputScript.getChunks();
>> byte[] program = chunks.get(chunks.size() - 1).data;
>> Script redeemScript = new Script(program);
>> Sha256Hash sighash = tx.hashForSignature(0, redeemScript,
>> Transaction.SigHash.ALL, false);
>> ECKey.ECDSASignature sig =
>> ECKey.ECDSASignature.decodeFromDER(signatureByThirdParty));
>> TransactionSignature txSig = new TransactionSignature(sig,
>> Transaction.SigHash.ALL, false);
>> byte[] txSigEncoded = txSig.encodeToBitcoin();
>> int sigIndex = inputScript.getSigInsertionIndex(sighash,
>> thirdPartyPubKey);
>> inputScript = ScriptBuilder.updateScriptWithSignature(inputScript,
>> txSig.encodeToBitcoin(), sigIndex, 1, 1);
>> txIn.setScriptSig(inputScript);
>>
>>
>>
>>
>> --
>> Oscar Guindzberg
>>
>> On Thu, Dec 29, 2016 at 8:20 AM, Álvaro Castro-Castilla
>> <[email protected]> wrote:
>> > I apologize for all this noise.
>> >
>> > That last error might be cause by calling broadcast(), instead of
>> > future().get(). Now the broadcast gets stuck and .get() blocks forever.
>> >
>> > I would appreciate any help on this :)
>> >
>> > Thank you!!
>> >
>> >
>> >
>> > On Thursday, December 29, 2016 at 11:51:14 AM UTC+1, Álvaro
>> > Castro-Castilla
>> > wrote:
>> >>
>> >> I think one reason was failure to call .broadcast() on the
>> >> BroadcastTransaction.
>> >>
>> >> Now I get 'bad-txns-inputs-duplicate' exception. The only input I add
>> >> to
>> >> the transaction (since this part is missing from the documentation) is
>> >> the
>> >> only one I get from the getUnspents() list from the wallet.
>> >>
>> >> The idea is to send the funds from my wallet to this multisig contract.
>> >> Is
>> >> this the correct approach?
>> >>
>> >> Thank you!
>> >>
>> >>
>> >>
>> >> On Thursday, December 29, 2016 at 12:29:05 AM UTC+1, Álvaro
>> >> Castro-Castilla wrote:
>> >>>
>> >>> Hi!
>> >>>
>> >>> I'm new to Bitcoinj. I'm trying to figure out the following:
>> >>> I want to create a wallet from where I can spend only with the input
>> >>> of
>> >>> 2-of-3 keys (a multisig).
>> >>>
>> >>> There are these two different texts in the documentation I've been
>> >>> reading:
>> >>>
>> >>>
>> >>>
>> >>> https://bitcoinj.github.io/working-with-contracts#creating-multi-signature-outputs
>> >>> and
>> >>>
>> >>>
>> >>> https://bitcoinj.github.io/working-with-the-wallet#marriedmulti-signature-wallets-and-pluggable-signers
>> >>>
>> >>> The first is better documented, and I've been giving it a try. I
>> >>> managed
>> >>> to:
>> >>> 1) Create a wallet
>> >>> 2) Send test bitcoins to the wallet (and check that the btc arrives)
>> >>> 3) Create a multisig contract with the previous transaction as input
>> >>> (from getUnspents), and the output being what is described in "Working
>> >>> with
>> >>> contracts"
>> >>>
>> >>> However, I can still spend the funds from the wallet, as if there was
>> >>> no
>> >>> 2-of-3 contract there. What am I missing? Or is it required to do the
>> >>> "married wallets" approach that is described in less detail in the
>> >>> other
>> >>> section?
>> >>>
>> >>> Thank you!
>> >
>> > --
>> > 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.
>>
>>
>>
>> --
>> Oscar Guindzberg
>
> --
> 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.



-- 
Oscar Guindzberg

-- 
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.

Reply via email to