Author

Topic: rawtransaction and multisignature (Read 782 times)

sr. member
Activity: 412
Merit: 287
July 03, 2015, 07:32:27 AM
#6
@init1: Most peoples problems are generally they need to write their wallet on top of bitcoind.

Also just checking, have you enabled the -txindex flag in bitcoin.conf to allow you to `getrawtransaction` on an arbitrary transaction?

Once you have the Address, and know a Txid / Vout / ScriptPubKey (comes from the address), you can create/verify signatures in your code, no bitcoind required. Try avoid using bitcoind RPC calls casually. They're slow and don't scale well, plus if you need it for 'validateaddress' or something, your site breaks if it goes offline or suffers heavy load.

Unfortunately for you, txindex only lets you look up by txid. You could use the addrindex patch to learn about txids on any address.
jr. member
Activity: 43
Merit: 7
July 02, 2015, 11:30:42 PM
#5
Use listunspent api to get txid and vout.

Hello, thanks. listunspent works if current address exists in the wallet. in my case I want to use rawtransaction without storing data into wallet.
sr. member
Activity: 412
Merit: 287
July 02, 2015, 11:00:17 AM
#4
AFAIK, the RPC has an addwatchonly command. This should notify you - regular walletnotify won't unless it has all the private keys for the multisig.

Otherwise, you could use blocknotify, and have a script parse every tx in every block for TxOuts where the script is something you know to look out for (payment to a particular address, etc). This is quite heavy.

You could use https://github.com/btcdrak/bitcoin/tree/addrindex <- lets you query ANY txid / address by virtue of a patch. As well as using -txindex=1, you use -addrindex=1, then your scripts can poll for information.

Another option is to write a Stratum client, and query public electrum servers for information. (there is an `blockchain.address.get_history` command you can send). This is probably the best thing to do IMO, as every single electrum client does this. You could query two to be sure they aren't feeding you bad results. It has the disadvantage however that you're directly sending your addresses over the wire. You can also subscribe to notifications to be received at a particular callback URL, or keep the socket open and you'll get them there.

Otherwise, go all out, and DIY Tongue Use bindings to the P2P network to to request filtered blocks from peers (only contains tx's which would be included in your filter). This is more private than Stratum, but requires a bit of work if you want access to historic transactions. But, if your service generates the address for users, you know transactions will only happen after that, so subscribe before your users know about it, and scour filtered blocks for transactions for your users. (Depending on your chosen false positive rate, you may have transactions that have nothing to do with your wallet.)

Otherwise you could use a web service's API.
hero member
Activity: 560
Merit: 509
I prefer Zakir over Muhammed when mentioning me!
sr. member
Activity: 324
Merit: 260
July 02, 2015, 05:37:52 AM
#2
Use listunspent api to get txid and vout.
jr. member
Activity: 43
Merit: 7
July 02, 2015, 04:19:14 AM
#1
Hello!

Could you please give some advice how to spend coins from multi-signature address.

I used native bitcoin client for interaction with bitcoin API

1) generated keys by seed https://brainwallet.org/#generator
Code:
#SEED 1 => nativeapi seed generatoin 1
#privateKey => 5J12tRNKL3VnVikXXShQDg34shBgLh5km3p6fi1ppAJ4Xdm2Vn5
#publicKey = 04cf3b0ab1eda3c2d17b20b6827f0bc3135c86a17dac2624cdf30d94ec32d57926c0bb849553b85bd82bb42ba8b807994ee31659904d587927ab7f3ca4d55e0df0
#
#SEED 2 => nativeapi seed generatoin 2
#privateKey => 5Jji5oEwmgNRunYVVh5DaEeKpe45VVpugdRWwabSHHC38LKuSUv
#publicKey = 043a021139c31de1ece897fe13af88b2c63c571378bd574ff994e3804ab76a7cf4f6d2d8fef3e1fa68bc97f9069574cdf57376f22977cb93460e5d2fd4ed0a2c07
#
#SEED 3 => nativeapi seed generatoin 3
#privateKey => 5Kih8h8TFbjKVuX866eVesrKLdwTfyNey6YQaYroHBzwtWvKrMa
#publicKey = 04a2242366abdbc2c32c6f42731b60f93bf7c1a860bd32b260c1d63b65e1ce0718d593bb644e98b6d083b80f55adb109e4a7161ce0f268e48c885f42f5653e03b9

2) createmultisig 2 '["04cf3b0ab1eda3c2d17b20b6827f0bc3135c86a17dac2624cdf30d94ec32d57926c0bb849553b85bd82bb42ba8b807994ee31659904d587927ab7f3ca4d55e0df0","043a021139c31de1ece897fe13af88b2c63c571378bd574ff994e3804ab76a7cf4f6d2d8fef3e1fa68bc97f9069574cdf57376f22977cb93460e5d2fd4ed0a2c07","04a2242366abdbc2c32c6f42731b60f93bf7c1a860bd32b260c1d63b65e1ce0718d593bb644e98b6d083b80f55adb109e4a7161ce0f268e48c885f42f5653e03b9"]'


Got 'address' and 'redeemScript'

Code:
"address" : "2MtmMhz1QJJiMvLFbMGPjbj8PeZxJpmKddg",
"redeemScript" : "524104cf3b0ab1eda3c2d17b20b6827f0bc3135c86a17dac2624cdf30d94ec32d57926c0bb849553b85bd82bb42ba8b807994ee31659904d587927ab7f3ca4d55e0df041043a021139c31de1ece897fe13af88b2c63c571378bd574ff994e3804ab76a7cf4f6d2d8fef3e1fa68bc97f9069574cdf57376f22977cb93460e5d2fd4ed0a2c074104a2242366abdbc2c32c6f42731b60f93bf7c1a860bd32b260c1d63b65e1ce0718d593bb644e98b6d083b80f55adb109e4a7161ce0f268e48c885f42f5653e03b953ae"
}
Checked this https://www.blocktrail.com/tBTC/address/2MtmMhz1QJJiMvLFbMGPjbj8PeZxJpmKddg address and send a few coins to the address by http://faucet.haskoin.com

Now I want to spent coins from this address

As I know I have to prepare raw transaction and sign it by 2 of 3

like this:
createrawtransaction
signrawtransaction
signrawtransaction
sendrawtransaction

for create raw TX need to use txid

Should I get txid for the address 2MtmMhz1QJJiMvLFbMGPjbj8PeZxJpmKddg ? and create rawtransaction like this

Code:
createrawtransaction '[{"txid":"2of3_address_txid","vout":0"}]' '{"destination_address":0.00010000}'

How can I get txid my created 2of3 address? any app`s web services ?

BR!
Jump to: