:: Re: [Libbitcoin] How to fill in scr…
Top Page
Delete this message
Reply to this message
Author: Chang Lan
Date:  
To: libbitcoin
Subject: Re: [Libbitcoin] How to fill in scriptSig
The “address” in both input and the second output is mnRQG7kRAapsriWL8hKHRWpw6AgSyWWmn4 in my machine. I have no idea why we saw difference. I built the libbitcoin with ‘—enable-testnet’.

I tried to make the transaction using ‘mktx’. Here is we I got:

$ sx mktx txfile.tx --input cb502ebca60cfe43bf0cd1c91a50ab07590eb8d35c3b2d29306693dfa36047d0:0 --output mnRQG7kRAapsriWL8hKHRWpw6AgSyWWmn4:309999990

Added input cb502ebca60cfe43bf0cd1c91a50ab07590eb8d35c3b2d29306693dfa36047d0:0
mktx: Unsupported address type.

mnRQG7kRAapsriWL8hKHRWpw6AgSyWWmn4 is the address I have:
https://blockexplorer.com/testnet/address/mnRQG7kRAapsriWL8hKHRWpw6AgSyWWmn4

Best,
Chang


On Sunday, December 8, 2013 at 1:21 PM, Amir Taaki wrote:

> Are you able to construct the tx using the command line tools sx?
>
> Then you can port the code as you use it piece by piece into your own
> application.
>
> You need to update sx from the git repository (that should be fixed).
> Here's what I see:
>
> hash: 43919afd984bf86a421bc5d32ddc25bbaad996d6429a0e6a81b6d6059aa86db2
> version: 1
> locktime: 0
> Input:
> previous output:
> cb502ebca60cfe43bf0cd1c91a50ab07590eb8d35c3b2d29306693dfa36047d0:0
> script: [
> 3045022100b4760147383d74cc68c1004755d3e210949370358309d5d64e81f3ec0e54ba470220540d21755a68946f19eaebb1b7b3c5649ee5825ac7363bdededcf445f2912a3001
> ] [
> 04a0160a564377fc9af6100827cf0726bf794aa57c6b908731b0cd6057da8a8ae01597c54fdce5b0b58cbd87de98821c71c638724dac5c93c7539d7f3351c20a5f
> ]
> sequence: 4294967295
> address: 17uSy4fSMZPd5c2iR8LubbccEB5jyJi9rc
> Output:
> value: 10
> script: 2 [
> 04a0160a564377fc9af6100827cf0726bf794aa57c6b908731b0cd6057da8a8ae01597c54fdce5b0b58cbd87de98821c71c638724dac5c93c7539d7f3351c20a5f
> ] [
> 04a0160a564377fc9af6100827cf0726bf794aa57c6b908731b0cd6057da8a8ae01597c54fdce5b0b58cbd87de98821c71c638724dac5c93c7539d7f3351c20a5f
> ] 2 checkmultisig
> Output:
> value: 309999990
> script: dup hash160 [ 4bbc0f7fff6b9135e3bf1a472b464ec127947cfb ]
> equalverify checksig
> address: 17uSy4fSMZPd5c2iR8LubbccEB5jyJi9rc
>
>
> On 08/12/13 21:18, Chang Lan wrote:
> > Thanks Amir!
> >
> > I am using testnet so the TXDATA is for testnet:
> >
> > 0100000001d04760a3df936630292d3b5cd3b80e5907ab501ac9d10cbf43fe0ca6bc2e50cb000000008b483045022100b4760147383d74cc68c1004755d3e210949370358309d5d64e81f3ec0e54ba470220540d21755a68946f19eaebb1b7b3c5649ee5825ac7363bdededcf445f2912a30014104a0160a564377fc9af6100827cf0726bf794aa57c6b908731b0cd6057da8a8ae01597c54fdce5b0b58cbd87de98821c71c638724dac5c93c7539d7f3351c20a5fffffffff020a0000000000000087524104a0160a564377fc9af6100827cf0726bf794aa57c6b908731b0cd6057da8a8ae01597c54fdce5b0b58cbd87de98821c71c638724dac5c93c7539d7f3351c20a5f4104a0160a564377fc9af6100827cf0726bf794aa57c6b908731b0cd6057da8a8ae01597c54fdce5b0b58cbd87de98821c71c638724dac5c93c7539d7f3351c20a5f52ae76397a12000000001976a9144bbc0f7fff6b9135e3bf1a472b464ec127947cfb88ac00000000
> >
> > sx showtx worked well but when I used the command
> >
> > echo TXDATA | sx validsx
> >
> > I got
> >
> > terminate called after throwing an instance of 'libbitcoin::end_of_stream’
> >
> > Best,
> > Chang
> >
> > On Sunday, December 8, 2013 at 12:59 PM, Amir Taaki wrote:
> >
> > > Hi,
> > >
> > > Your code looks correct. You can use the command:
> > >
> > > echo TXDATA | sx validtx
> > >
> > > to check the correctness of the tx (but I'm not sure if the reported
> > > erros are always correct - I need to investigate that).
> > >
> > > You can also examine the data using:
> > >
> > > echo TXDATA | sx showtx
> > >
> > > your sign code is correct, and the other code looks good. If you give me
> > > the hex I can see if I spot anything.
> > >
> > > Here's some code for constructing transactions:
> > >
> > > https://github.com/spesmilo/sx/blob/master/src/wallet.cpp
> > > (see line 361 to 521)
> > >
> > > https://github.com/darkwallet/python-obelisk/blob/master/examples/mktx.py
> > > https://github.com/darkwallet/python-obelisk/blob/master/obelisk/bitcoin.py
> > > (see line 998)
> > >
> > > On 08/12/13 20:50, Chang Lan wrote:
> > > > Hi there,
> > > >
> > > > I tried making a valid transaction using libbitcoin, but it seems that
> > > > the transaction turns out to be invalid. Below is the code snippet that
> > > > I used to create a transaction. Can anyone point out if I did it wrong?
> > > > Thanks!
> > > >
> > > > void add_input(transaction_type& tx, const output_point& output)
> > > > {
> > > > transaction_input_type input;
> > > > output_point& prevout = input.previous_output;
> > > > prevout = output;
> > > > input.sequence = 4294967295;
> > > > tx.inputs.push_back(input);
> > > > }
> > > >
> > > >
> > > > bool sign(transaction_type& tx, size_t input_index, const
> > > > elliptic_curve_key& key, const script_type& script_code)
> > > > {
> > > > transaction_input_type& input = tx.inputs[input_index];
> > > > const data_chunk public_key = key.public_key();
> > > > if (public_key.empty())
> > > > {
> > > > std::cerr << "internal error getting public key" << std::endl;
> > > > return false;
> > > > }
> > > > hash_digest tx_hash = script_type::generate_signature_hash(tx,
> > > > input_index, script_code, 1);
> > > > if (tx_hash == null_hash)
> > > > {
> > > > std::cerr << "error generating signature hash" << std::endl;
> > > > return false;
> > > > }
> > > > data_chunk signature = key.sign(tx_hash);
> > > > signature.push_back(0x01);
> > > >
> > > > script_type input_script;
> > > > input_script.push_operation({opcode::special, signature});
> > > > std::cout << key.public_key().size() << std::endl;
> > > > input_script.push_operation({opcode::special, key.public_key()});
> > > > tx.inputs[input_index].script = input_script;
> > > >
> > > > return true;
> > > > }
> > > >
> > > >
> > > > bool create_channel_tx(transaction_type& tx, const data_chunk&
> > > > payee_public_key, const data_chunk& payer_public_key, uint64_t value)
> > > > {
> > > > /* … */
> > > > */* called add_input() for each input */*
> > > > // output 1
> > > > script_type out_script = build_contract_script(acc.key.public_key(),
> > > > remote_public_key);
> > > > transaction_output_type output;
> > > > output.value = value;
> > > > output.script = out_script;
> > > > tx.outputs.push_back(output);
> > > > // output 2
> > > > payment_address payaddr;
> > > > set_public_key(payaddr, acc.key.public_key());
> > > > script_type back_script = build_pubkey_hash_script(payaddr.hash());
> > > > transaction_output_type back_output;
> > > > back_output.value = collected_value - value;
> > > > back_output.script = back_script;
> > > > tx.outputs.push_back(back_output);
> > > >
> > > > // sign each input
> > > > for (size_t i = 0; i < tx.inputs.size(); ++i)
> > > > {
> > > > sign(tx, i, acc.key, back_script);
> > > > }
> > > > return true;
> > > > }
> > > >
> > > >
> > > > Chang
> > > >
> > > >
> > > >
> > > > _______________________________________________
> > > > Libbitcoin mailing list
> > > > Libbitcoin@??? <mailto:Libbitcoin@lists.dyne.org>
> > > > https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/libbitcoin
> > > >
> > >
> > > _______________________________________________
> > > Libbitcoin mailing list
> > > Libbitcoin@??? <mailto:Libbitcoin@lists.dyne.org>
> > > https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/libbitcoin
> > >
> >
> >
>
>
>