madmadmax (OP)
|
|
May 26, 2013, 05:19:53 AM |
|
Say I use the standard bitcoin-qt, how can I sign a transaction with public keys from the currently loaded wallet and other specific inputs from private keys without importing them?
|
▄▄▄▄▄ ▄▄▄▄▄ ▄▄█▀▀▀▀▀▀██▄ ▄▄█▀▀▀▀▀▀▀█▄ ▄██▀ ▀██▄ ▄██▀ ▀█▄ ██▀ ▀██▄ ▀▀ ██ ██ ▀██ ▄▄▄▄▄▄▄▄██ ██ ▀██▄ ▀▀▀▀▀▀▀▀▀▀ ██▄ ▄██ ▀██▄ ▄▄▄ ▀██▄ ▄██▀ ▀██▄▄ ▄██▀ ▀▀██████▀▀ ▀▀██████▀▀
| | █ ║ █ | ✔ Unchained Smart Contracts ✔ Decentralized Oracle ✔ Infinitly Scalable
| ✔ Blockchain Technology ✔ Turing-Complete ✔ State-Channels
| █ ║ █ | ▄████▄▄ ▄ ██ ████████████▀ ████▄ █████████████▀ ▀████████▄▄ █████████████ ▄▄█████████████████████████ ██████████████████████████ ▀██████████████████████ █████████████████████ ▀█████████████████▀ ▄█████████████▀ ▄▄███████████████▀ ▀▀▀▀▀▀▀▀▀▀▀
| | ▄██▄ ▄ ▐████ ▄▄ █████ ██████████ █████████████████▀ ▄████████████▀████▌ ██████████ ▀████ ▀▀ █████ ██████████ ▀████▌▄████████████▀ ▄▄▄███████████████▌ ██████████▀ ▐████ ▀▀▀ ████▌ ▀▀▀ ▀███▀
| | f | | █ ║ █ | |
|
|
|
scintill
|
|
May 26, 2013, 06:03:19 AM |
|
Assuming you're already dealing with a raw transaction, the signrawtransaction command lets you specify additional private keys as an optional last parameter. I think for keys already in your wallet (and referenced by the raw transaction), it will find them automatically. createrawtransaction takes arbitrary outputs and address:amount pairs and creates a hex transaction string. listunspent will show you the unspent outputs for keys that are in your wallet.
|
1SCiN5kqkAbxxwesKMsH9GvyWnWP5YK2W | donations
|
|
|
madmadmax (OP)
|
|
May 26, 2013, 11:22:29 AM |
|
Assuming you're already dealing with a raw transaction, the signrawtransaction command lets you specify additional private keys as an optional last parameter. I think for keys already in your wallet (and referenced by the raw transaction), it will find them automatically. createrawtransaction takes arbitrary outputs and address:amount pairs and creates a hex transaction string. listunspent will show you the unspent outputs for keys that are in your wallet. The problem is I don't want to use all of the input under that private key, just half here and half under the private key.
|
▄▄▄▄▄ ▄▄▄▄▄ ▄▄█▀▀▀▀▀▀██▄ ▄▄█▀▀▀▀▀▀▀█▄ ▄██▀ ▀██▄ ▄██▀ ▀█▄ ██▀ ▀██▄ ▀▀ ██ ██ ▀██ ▄▄▄▄▄▄▄▄██ ██ ▀██▄ ▀▀▀▀▀▀▀▀▀▀ ██▄ ▄██ ▀██▄ ▄▄▄ ▀██▄ ▄██▀ ▀██▄▄ ▄██▀ ▀▀██████▀▀ ▀▀██████▀▀
| | █ ║ █ | ✔ Unchained Smart Contracts ✔ Decentralized Oracle ✔ Infinitly Scalable
| ✔ Blockchain Technology ✔ Turing-Complete ✔ State-Channels
| █ ║ █ | ▄████▄▄ ▄ ██ ████████████▀ ████▄ █████████████▀ ▀████████▄▄ █████████████ ▄▄█████████████████████████ ██████████████████████████ ▀██████████████████████ █████████████████████ ▀█████████████████▀ ▄█████████████▀ ▄▄███████████████▀ ▀▀▀▀▀▀▀▀▀▀▀
| | ▄██▄ ▄ ▐████ ▄▄ █████ ██████████ █████████████████▀ ▄████████████▀████▌ ██████████ ▀████ ▀▀ █████ ██████████ ▀████▌▄████████████▀ ▄▄▄███████████████▌ ██████████▀ ▐████ ▀▀▀ ████▌ ▀▀▀ ▀███▀
| | f | | █ ║ █ | |
|
|
|
DannyHamilton
Legendary
Offline
Activity: 3486
Merit: 4851
|
|
May 26, 2013, 01:53:43 PM |
|
Assuming you're already dealing with a raw transaction, the signrawtransaction command lets you specify additional private keys as an optional last parameter. I think for keys already in your wallet (and referenced by the raw transaction), it will find them automatically. createrawtransaction takes arbitrary outputs and address:amount pairs and creates a hex transaction string. listunspent will show you the unspent outputs for keys that are in your wallet. The problem is I don't want to use all of the input under that private key, just half here and half under the private key. I'm not sure if you are saying that there are multiple outputs associated with the private key, and you don't want to use all of them as inputs to your transaction. . . Or if you are saying there is only one output associated with the private key, and you don't want to use all of that output as an input. If there are multiple outputs, then createrawtransaction allows you to specify which of those outputs you want to use as inputs, so you don't have to use all of them if you don't want to. If there is only one output, then you have to use the entire output. That's how bitcoin works. It is not possible to only use a portion of an output. The output is spent completely as an input, and then you have to create a new output that sends any excess back to your wallet. If you forget to create the output that sends the "change" from the transaction back to your wallet, then the miner will get all of it as a transaction fee.
|
|
|
|
scintill
|
|
May 27, 2013, 12:28:41 AM |
|
The problem is I don't want to use all of the input under that private key, just half here and half under the private key.
As DannyHamilton said, you pick whatever outputs you want. listunspent just shows you your options. Remember you have to spend an output's entire balance at once, though. To clarify on automatically finding keys, you give createrawtransaction the outputs you want to spend, which embeds them into the hex string it returns. signrawtransaction looks at those outputs, figures out the associated key, and signs them if it has the associated private key in its wallet or specified on the command line. None of these steps will automatically add outputs/inputs, they only do what you tell them to.
|
1SCiN5kqkAbxxwesKMsH9GvyWnWP5YK2W | donations
|
|
|
madmadmax (OP)
|
|
May 27, 2013, 04:35:05 AM |
|
Assuming you're already dealing with a raw transaction, the signrawtransaction command lets you specify additional private keys as an optional last parameter. I think for keys already in your wallet (and referenced by the raw transaction), it will find them automatically. createrawtransaction takes arbitrary outputs and address:amount pairs and creates a hex transaction string. listunspent will show you the unspent outputs for keys that are in your wallet. The problem is I don't want to use all of the input under that private key, just half here and half under the private key. I'm not sure if you are saying that there are multiple outputs associated with the private key, and you don't want to use all of them as inputs to your transaction. . . Or if you are saying there is only one output associated with the private key, and you don't want to use all of that output as an input. If there are multiple outputs, then createrawtransaction allows you to specify which of those outputs you want to use as inputs, so you don't have to use all of them if you don't want to. If there is only one output, then you have to use the entire output. That's how bitcoin works. It is not possible to only use a portion of an output. The output is spent completely as an input, and then you have to create a new output that sends any excess back to your wallet. If you forget to create the output that sends the "change" from the transaction back to your wallet, then the miner will get all of it as a transaction fee. The problem is I don't want to use all of the input under that private key, just half here and half under the private key.
As DannyHamilton said, you pick whatever outputs you want. listunspent just shows you your options. Remember you have to spend an output's entire balance at once, though. To clarify on automatically finding keys, you give createrawtransaction the outputs you want to spend, which embeds them into the hex string it returns. signrawtransaction looks at those outputs, figures out the associated key, and signs them if it has the associated private key in its wallet or specified on the command line. None of these steps will automatically add outputs/inputs, they only do what you tell them to. Yes I understand that, what I'm asking is whenever I can create a raw transaction with inputs from the current listunspent and add another input which isn't on listunspent but from a different wallet and then just specify the private key on createrawtransaction?
|
▄▄▄▄▄ ▄▄▄▄▄ ▄▄█▀▀▀▀▀▀██▄ ▄▄█▀▀▀▀▀▀▀█▄ ▄██▀ ▀██▄ ▄██▀ ▀█▄ ██▀ ▀██▄ ▀▀ ██ ██ ▀██ ▄▄▄▄▄▄▄▄██ ██ ▀██▄ ▀▀▀▀▀▀▀▀▀▀ ██▄ ▄██ ▀██▄ ▄▄▄ ▀██▄ ▄██▀ ▀██▄▄ ▄██▀ ▀▀██████▀▀ ▀▀██████▀▀
| | █ ║ █ | ✔ Unchained Smart Contracts ✔ Decentralized Oracle ✔ Infinitly Scalable
| ✔ Blockchain Technology ✔ Turing-Complete ✔ State-Channels
| █ ║ █ | ▄████▄▄ ▄ ██ ████████████▀ ████▄ █████████████▀ ▀████████▄▄ █████████████ ▄▄█████████████████████████ ██████████████████████████ ▀██████████████████████ █████████████████████ ▀█████████████████▀ ▄█████████████▀ ▄▄███████████████▀ ▀▀▀▀▀▀▀▀▀▀▀
| | ▄██▄ ▄ ▐████ ▄▄ █████ ██████████ █████████████████▀ ▄████████████▀████▌ ██████████ ▀████ ▀▀ █████ ██████████ ▀████▌▄████████████▀ ▄▄▄███████████████▌ ██████████▀ ▐████ ▀▀▀ ████▌ ▀▀▀ ▀███▀
| | f | | █ ║ █ | |
|
|
|
scintill
|
|
May 27, 2013, 06:14:17 AM |
|
Yes I understand that, what I'm asking is whenever I can create a raw transaction with inputs from the current listunspent and add another input which isn't on listunspent but from a different wallet and then just specify the private key on createrawtransaction?
Actually, I just noticed this in the help message for signrawtransaction: Third optional argument (may be null) is an array of base58-encoded private keys that, if given, will be the only keys used to sign the transaction.
So, if you don't specify that parameter, it will find keys in your wallet, but can only use the ones that are in it. If you do give it, it won't look in your wallet. My tests seem to confirm this. A way around this that seemed to work for me for a test with 2 keys (one in wallet, one not), was to signrawtransaction with no keys, which gave a partially-signed transaction from the wallet key. Then I copied the output into another signrawtransaction and passed the remaining private key as a parameter. The result had "complete":true and the decoded transaction appeared to have both signatures, so I think that would work. I'm not sure if there's a nicer way to do this. Maybe someone with more experience with the RPC API knows. The raw transactions wiki page may also be helpful.
|
1SCiN5kqkAbxxwesKMsH9GvyWnWP5YK2W | donations
|
|
|
madmadmax (OP)
|
|
May 28, 2013, 04:36:14 AM |
|
Yes I understand that, what I'm asking is whenever I can create a raw transaction with inputs from the current listunspent and add another input which isn't on listunspent but from a different wallet and then just specify the private key on createrawtransaction?
Actually, I just noticed this in the help message for signrawtransaction: Third optional argument (may be null) is an array of base58-encoded private keys that, if given, will be the only keys used to sign the transaction.
So, if you don't specify that parameter, it will find keys in your wallet, but can only use the ones that are in it. If you do give it, it won't look in your wallet. My tests seem to confirm this. A way around this that seemed to work for me for a test with 2 keys (one in wallet, one not), was to signrawtransaction with no keys, which gave a partially-signed transaction from the wallet key. Then I copied the output into another signrawtransaction and passed the remaining private key as a parameter. The result had "complete":true and the decoded transaction appeared to have both signatures, so I think that would work. I'm not sure if there's a nicer way to do this. Maybe someone with more experience with the RPC API knows. The raw transactions wiki page may also be helpful. Thanks!! What did you pass as the second argument?
|
▄▄▄▄▄ ▄▄▄▄▄ ▄▄█▀▀▀▀▀▀██▄ ▄▄█▀▀▀▀▀▀▀█▄ ▄██▀ ▀██▄ ▄██▀ ▀█▄ ██▀ ▀██▄ ▀▀ ██ ██ ▀██ ▄▄▄▄▄▄▄▄██ ██ ▀██▄ ▀▀▀▀▀▀▀▀▀▀ ██▄ ▄██ ▀██▄ ▄▄▄ ▀██▄ ▄██▀ ▀██▄▄ ▄██▀ ▀▀██████▀▀ ▀▀██████▀▀
| | █ ║ █ | ✔ Unchained Smart Contracts ✔ Decentralized Oracle ✔ Infinitly Scalable
| ✔ Blockchain Technology ✔ Turing-Complete ✔ State-Channels
| █ ║ █ | ▄████▄▄ ▄ ██ ████████████▀ ████▄ █████████████▀ ▀████████▄▄ █████████████ ▄▄█████████████████████████ ██████████████████████████ ▀██████████████████████ █████████████████████ ▀█████████████████▀ ▄█████████████▀ ▄▄███████████████▀ ▀▀▀▀▀▀▀▀▀▀▀
| | ▄██▄ ▄ ▐████ ▄▄ █████ ██████████ █████████████████▀ ▄████████████▀████▌ ██████████ ▀████ ▀▀ █████ ██████████ ▀████▌▄████████████▀ ▄▄▄███████████████▌ ██████████▀ ▐████ ▀▀▀ ████▌ ▀▀▀ ▀███▀
| | f | | █ ║ █ | |
|
|
|
scintill
|
|
May 29, 2013, 02:38:30 AM |
|
Thanks!!
What did you pass as the second argument?
Null. So signrawtransaction <hex string> null '["5Ksdfsd..."]' For the key-in-wallet part you can just give the hex string and it will default to null for the 2nd parameter.
|
1SCiN5kqkAbxxwesKMsH9GvyWnWP5YK2W | donations
|
|
|
kodo
Newbie
Offline
Activity: 42
Merit: 0
|
|
May 29, 2013, 04:54:54 AM |
|
hmm im not sure about this.
|
|
|
|
madmadmax (OP)
|
|
May 29, 2013, 06:05:52 PM |
|
Thanks!!
What did you pass as the second argument?
Null. So signrawtransaction <hex string> null '["5Ksdfsd..."]' For the key-in-wallet part you can just give the hex string and it will default to null for the 2nd parameter. Thanks!!!!
|
▄▄▄▄▄ ▄▄▄▄▄ ▄▄█▀▀▀▀▀▀██▄ ▄▄█▀▀▀▀▀▀▀█▄ ▄██▀ ▀██▄ ▄██▀ ▀█▄ ██▀ ▀██▄ ▀▀ ██ ██ ▀██ ▄▄▄▄▄▄▄▄██ ██ ▀██▄ ▀▀▀▀▀▀▀▀▀▀ ██▄ ▄██ ▀██▄ ▄▄▄ ▀██▄ ▄██▀ ▀██▄▄ ▄██▀ ▀▀██████▀▀ ▀▀██████▀▀
| | █ ║ █ | ✔ Unchained Smart Contracts ✔ Decentralized Oracle ✔ Infinitly Scalable
| ✔ Blockchain Technology ✔ Turing-Complete ✔ State-Channels
| █ ║ █ | ▄████▄▄ ▄ ██ ████████████▀ ████▄ █████████████▀ ▀████████▄▄ █████████████ ▄▄█████████████████████████ ██████████████████████████ ▀██████████████████████ █████████████████████ ▀█████████████████▀ ▄█████████████▀ ▄▄███████████████▀ ▀▀▀▀▀▀▀▀▀▀▀
| | ▄██▄ ▄ ▐████ ▄▄ █████ ██████████ █████████████████▀ ▄████████████▀████▌ ██████████ ▀████ ▀▀ █████ ██████████ ▀████▌▄████████████▀ ▄▄▄███████████████▌ ██████████▀ ▐████ ▀▀▀ ████▌ ▀▀▀ ▀███▀
| | f | | █ ║ █ | |
|
|
|
kodo
Newbie
Offline
Activity: 42
Merit: 0
|
|
May 29, 2013, 06:21:04 PM |
|
Glad you got this worked out.
|
|
|
|
madmadmax (OP)
|
|
May 30, 2013, 12:50:42 PM |
|
Glad you got this worked out.
I get "Expected type array, got str" for some reason, this is what I send: {"jsonrpc":"1.0","id":"1","method":"signrawtransaction","params":[" myhex","null",[" myprivatekey"]]} where have I went wrong?
|
▄▄▄▄▄ ▄▄▄▄▄ ▄▄█▀▀▀▀▀▀██▄ ▄▄█▀▀▀▀▀▀▀█▄ ▄██▀ ▀██▄ ▄██▀ ▀█▄ ██▀ ▀██▄ ▀▀ ██ ██ ▀██ ▄▄▄▄▄▄▄▄██ ██ ▀██▄ ▀▀▀▀▀▀▀▀▀▀ ██▄ ▄██ ▀██▄ ▄▄▄ ▀██▄ ▄██▀ ▀██▄▄ ▄██▀ ▀▀██████▀▀ ▀▀██████▀▀
| | █ ║ █ | ✔ Unchained Smart Contracts ✔ Decentralized Oracle ✔ Infinitly Scalable
| ✔ Blockchain Technology ✔ Turing-Complete ✔ State-Channels
| █ ║ █ | ▄████▄▄ ▄ ██ ████████████▀ ████▄ █████████████▀ ▀████████▄▄ █████████████ ▄▄█████████████████████████ ██████████████████████████ ▀██████████████████████ █████████████████████ ▀█████████████████▀ ▄█████████████▀ ▄▄███████████████▀ ▀▀▀▀▀▀▀▀▀▀▀
| | ▄██▄ ▄ ▐████ ▄▄ █████ ██████████ █████████████████▀ ▄████████████▀████▌ ██████████ ▀████ ▀▀ █████ ██████████ ▀████▌▄████████████▀ ▄▄▄███████████████▌ ██████████▀ ▐████ ▀▀▀ ████▌ ▀▀▀ ▀███▀
| | f | | █ ║ █ | |
|
|
|
kjj
Legendary
Offline
Activity: 1302
Merit: 1026
|
|
May 30, 2013, 01:15:04 PM |
|
Erm, I'm pretty sure you need to pass in an empty array there, and not the string "null".
|
17Np17BSrpnHCZ2pgtiMNnhjnsWJ2TMqq8 I routinely ignore posters with paid advertising in their sigs. You should too.
|
|
|
madmadmax (OP)
|
|
May 30, 2013, 02:43:33 PM |
|
Erm, I'm pretty sure you need to pass in an empty array there, and not the string "null".
Nope, if I pass it empty I still get the same error.
|
▄▄▄▄▄ ▄▄▄▄▄ ▄▄█▀▀▀▀▀▀██▄ ▄▄█▀▀▀▀▀▀▀█▄ ▄██▀ ▀██▄ ▄██▀ ▀█▄ ██▀ ▀██▄ ▀▀ ██ ██ ▀██ ▄▄▄▄▄▄▄▄██ ██ ▀██▄ ▀▀▀▀▀▀▀▀▀▀ ██▄ ▄██ ▀██▄ ▄▄▄ ▀██▄ ▄██▀ ▀██▄▄ ▄██▀ ▀▀██████▀▀ ▀▀██████▀▀
| | █ ║ █ | ✔ Unchained Smart Contracts ✔ Decentralized Oracle ✔ Infinitly Scalable
| ✔ Blockchain Technology ✔ Turing-Complete ✔ State-Channels
| █ ║ █ | ▄████▄▄ ▄ ██ ████████████▀ ████▄ █████████████▀ ▀████████▄▄ █████████████ ▄▄█████████████████████████ ██████████████████████████ ▀██████████████████████ █████████████████████ ▀█████████████████▀ ▄█████████████▀ ▄▄███████████████▀ ▀▀▀▀▀▀▀▀▀▀▀
| | ▄██▄ ▄ ▐████ ▄▄ █████ ██████████ █████████████████▀ ▄████████████▀████▌ ██████████ ▀████ ▀▀ █████ ██████████ ▀████▌▄████████████▀ ▄▄▄███████████████▌ ██████████▀ ▐████ ▀▀▀ ████▌ ▀▀▀ ▀███▀
| | f | | █ ║ █ | |
|
|
|
kjj
Legendary
Offline
Activity: 1302
Merit: 1026
|
|
May 30, 2013, 04:31:11 PM |
|
Are you passing an empty array, or an empty string?
'[]'
|
17Np17BSrpnHCZ2pgtiMNnhjnsWJ2TMqq8 I routinely ignore posters with paid advertising in their sigs. You should too.
|
|
|
scintill
|
|
May 30, 2013, 06:04:43 PM |
|
My use of null was at the Debug Console in bitcoin-qt, so maybe it's different for JSON-RPC. I don't know the RPC format, but assuming you're basically right, I would try:
{"jsonrpc":"1.0","id":"1","method":"signrawtransaction","params":["myhex",[],["myprivatekey"]]} {"jsonrpc":"1.0","id":"1","method":"signrawtransaction","params":["myhex",null,["myprivatekey"]]}
|
1SCiN5kqkAbxxwesKMsH9GvyWnWP5YK2W | donations
|
|
|
|