Matt Whitlock [ARCHIVE] on Nostr: 📅 Original date posted:2014-04-15 📝 Original message:On Tuesday, 15 April 2014, ...
📅 Original date posted:2014-04-15
📝 Original message:On Tuesday, 15 April 2014, at 8:47 am, Mike Belshe wrote:
> For what it is worth, I found btcd (the go implementation of bitcoind) has
> much better error/diagnostics messages. It would have given you more than
> "-22 TX Rejected". I used it to debug my own multi-sig transactions and it
> was very helpful.
I'll have to check that out.
A follow-up on my initial post... I did just successfully create, sign, and transmit another 2-of-3 transaction, so once again, I'm sorry I bothered this list. But since I did (and am now doing so again), I'll give a little more background on what we've been up to. It's not quite as simple as what I've shared thus far.
We have built a tool from scratch in C++ that is kind of a Swiss Army knife of Bitcoin. It does all sorts of key and address conversions, hash functions, encoding and decoding, script disassembly, BIP38 encryption/decrytion, the Shamir Secret Sharing that I've posted about here on this list before, and transaction building and signing. It has its own wallet and it's own UTXO cache that contains only TXOs that are relevant to the objects in its wallet. It synchronizes its cache by scanning bitcoind's block data files. (It memory maps them and can do a full scan of the entire block chain in about a minute!) The wallet can contain keys, seeds, and multi-signature aggregates (which in turn can comprise keys and seeds). What we've been testing is deriving sequences of multi-sig P2SH addresses from a set of public seeds, sending bitcoins to those addresses, then using our tool to find those outputs in the block chain and to create transactions that redeem them, and then signing those transactions by supplying the private seeds to the tool.
Our tool is quite a bit easier to use than Bitcoind. (I was frankly appalled at the command-line syntax that was necessary to get Bitcoind to sign a P2SH multi-sig transaction.)
$ ./btctool privkey < /dev/random > privseed1
$ ./btctool privkey < /dev/random > privseed2
$ ./btctool privkey < /dev/random > privseed3
$ pubseed1=$(./btctool pubkey < privseed1)
$ pubseed2=$(./btctool pubkey < privseed2)
$ pubseed3=$(./btctool pubkey < privseed3)
$ ./chaintool init
$ ./chaintool add demo 2 ":${pubseed1}" ":${pubseed2}" ":${pubseed3}"
$ ./chaintool ls
demo 2 :036447c7edc861b9f41fa0f611d81784f19ce692f37e8772b55c37c743cd526b49 :03c831711ea65decc06b0f3ccb4b9f1ba1a99a6933e520f6e7e4c3dbb4f015b701 :0347f2a0a346f21538fc451b95a600bc64ce5d2d28b89bf547697f3a77195d8dd1
$ ./btctool addresses 1 2 "${pubseed1}" "${pubseed2}" "${pubseed3}"
3GQd1tosFCE7Vo4TAiDHEKTaBgoyZTeL6R
$ bitcoind sendtoaddress 3GQd1tosFCE7Vo4TAiDHEKTaBgoyZTeL6R 0.01
6a9538f496f4c2d7f50c342fa6f6f76904a3b19f55f3a54a0003fc00b327d81b
(I waited here for the tx to get into a block)
$ ./chaintool sync /var/lib/bitcoin/.bitcoin/blocks 2> /dev/null
$ ./chaintool listunspent
[
{
"txid": "6a9538f496f4c2d7f50c342fa6f6f76904a3b19f55f3a54a0003fc00b327d81b",
"vout": 1,
"address": "3GQd1tosFCE7Vo4TAiDHEKTaBgoyZTeL6R",
"scriptPubKey": "a914a1701be36532f05a74511fca89afce180c58189587",
"amount": 1000000,
"confirmations": 1
}
]
$ cat > outputs << EOF
> 13QAKNuh9uFcEiNAsct6LSF1qWQR6HLarT 50000
> 1FV4Fm3VCXfWy7BAXzT8t5qqTvEKZSad9v
> EOF
$ tx=$(./chaintool createtx 10000 demo < outputs)
(I manually edited ${tx} at this point to add an OP_RETURN output. We're currently working toward using OP_RETURN in a provable solvency scheme.)
$ signedtx1=$(./chaintool signtx "${tx}" < privseed1)
input #0: need 1 of [:03c831711ea65decc06b0f3ccb4b9f1ba1a99a6933e520f6e7e4c3dbb4f015b701, :0347f2a0a346f21538fc451b95a600bc64ce5d2d28b89bf547697f3a77195d8dd1]
$ signedtx2=$(./chaintool signtx "${signedtx1}" < privseed2)
$ bitcoind sendrawtransaction "${signedtx2}"
b485b185c77d803f75e1ccfee1b5072846c9e0728f4c955ca40dce82263f8f16
$ exit
:-)
Published at
2023-06-07 15:18:37Event JSON
{
"id": "d64f01372c0e0a1aeda069531c9399e7aca0dffa63f07861239657e921dd0acb",
"pubkey": "f00d0858b09287e941ccbc491567cc70bdbc62d714628b167c1b76e7fef04d91",
"created_at": 1686151117,
"kind": 1,
"tags": [
[
"e",
"b1081907a3decdbf6a84447f24c9c7defcfbbfd883e2139aec6fd057d31eb12a",
"",
"root"
],
[
"e",
"1eaeb3dc90d593feb5ea1343e20ce92103bd4bbab57af4796b8b6e1aff7c5ed5",
"",
"reply"
],
[
"p",
"8b7a84ef686d23ec862f307eb53027acd8b23a2034e98167d7ea50a0bb599ca1"
]
],
"content": "📅 Original date posted:2014-04-15\n📝 Original message:On Tuesday, 15 April 2014, at 8:47 am, Mike Belshe wrote:\n\u003e For what it is worth, I found btcd (the go implementation of bitcoind) has\n\u003e much better error/diagnostics messages. It would have given you more than\n\u003e \"-22 TX Rejected\". I used it to debug my own multi-sig transactions and it\n\u003e was very helpful.\n\nI'll have to check that out.\n\n\nA follow-up on my initial post... I did just successfully create, sign, and transmit another 2-of-3 transaction, so once again, I'm sorry I bothered this list. But since I did (and am now doing so again), I'll give a little more background on what we've been up to. It's not quite as simple as what I've shared thus far. \n\nWe have built a tool from scratch in C++ that is kind of a Swiss Army knife of Bitcoin. It does all sorts of key and address conversions, hash functions, encoding and decoding, script disassembly, BIP38 encryption/decrytion, the Shamir Secret Sharing that I've posted about here on this list before, and transaction building and signing. It has its own wallet and it's own UTXO cache that contains only TXOs that are relevant to the objects in its wallet. It synchronizes its cache by scanning bitcoind's block data files. (It memory maps them and can do a full scan of the entire block chain in about a minute!) The wallet can contain keys, seeds, and multi-signature aggregates (which in turn can comprise keys and seeds). What we've been testing is deriving sequences of multi-sig P2SH addresses from a set of public seeds, sending bitcoins to those addresses, then using our tool to find those outputs in the block chain and to create transactions that redeem them, and then signing those transactions by supplying the private seeds to the tool.\n\nOur tool is quite a bit easier to use than Bitcoind. (I was frankly appalled at the command-line syntax that was necessary to get Bitcoind to sign a P2SH multi-sig transaction.)\n\n$ ./btctool privkey \u003c /dev/random \u003e privseed1\n$ ./btctool privkey \u003c /dev/random \u003e privseed2\n$ ./btctool privkey \u003c /dev/random \u003e privseed3\n$ pubseed1=$(./btctool pubkey \u003c privseed1)\n$ pubseed2=$(./btctool pubkey \u003c privseed2)\n$ pubseed3=$(./btctool pubkey \u003c privseed3)\n$ ./chaintool init\n$ ./chaintool add demo 2 \":${pubseed1}\" \":${pubseed2}\" \":${pubseed3}\"\n$ ./chaintool ls\ndemo 2 :036447c7edc861b9f41fa0f611d81784f19ce692f37e8772b55c37c743cd526b49 :03c831711ea65decc06b0f3ccb4b9f1ba1a99a6933e520f6e7e4c3dbb4f015b701 :0347f2a0a346f21538fc451b95a600bc64ce5d2d28b89bf547697f3a77195d8dd1\n$ ./btctool addresses 1 2 \"${pubseed1}\" \"${pubseed2}\" \"${pubseed3}\"\n3GQd1tosFCE7Vo4TAiDHEKTaBgoyZTeL6R\n$ bitcoind sendtoaddress 3GQd1tosFCE7Vo4TAiDHEKTaBgoyZTeL6R 0.01\n6a9538f496f4c2d7f50c342fa6f6f76904a3b19f55f3a54a0003fc00b327d81b\n(I waited here for the tx to get into a block)\n$ ./chaintool sync /var/lib/bitcoin/.bitcoin/blocks 2\u003e /dev/null\n$ ./chaintool listunspent\n[\n {\n \"txid\": \"6a9538f496f4c2d7f50c342fa6f6f76904a3b19f55f3a54a0003fc00b327d81b\",\n \"vout\": 1,\n \"address\": \"3GQd1tosFCE7Vo4TAiDHEKTaBgoyZTeL6R\",\n \"scriptPubKey\": \"a914a1701be36532f05a74511fca89afce180c58189587\",\n \"amount\": 1000000,\n \"confirmations\": 1\n }\n]\n$ cat \u003e outputs \u003c\u003c EOF\n\u003e 13QAKNuh9uFcEiNAsct6LSF1qWQR6HLarT 50000\n\u003e 1FV4Fm3VCXfWy7BAXzT8t5qqTvEKZSad9v\n\u003e EOF\n$ tx=$(./chaintool createtx 10000 demo \u003c outputs)\n(I manually edited ${tx} at this point to add an OP_RETURN output. We're currently working toward using OP_RETURN in a provable solvency scheme.)\n$ signedtx1=$(./chaintool signtx \"${tx}\" \u003c privseed1)\ninput #0: need 1 of [:03c831711ea65decc06b0f3ccb4b9f1ba1a99a6933e520f6e7e4c3dbb4f015b701, :0347f2a0a346f21538fc451b95a600bc64ce5d2d28b89bf547697f3a77195d8dd1]\n$ signedtx2=$(./chaintool signtx \"${signedtx1}\" \u003c privseed2)\n$ bitcoind sendrawtransaction \"${signedtx2}\"\nb485b185c77d803f75e1ccfee1b5072846c9e0728f4c955ca40dce82263f8f16\n$ exit\n\n:-)",
"sig": "163da1d03dbfe7e2482bcdc8c4f511b89305abe77a0c72d62e797f712d517830d082716902992dc53e7027e83f254e0460d0067b9dc5d87d2a0ff3cee1f066d3"
}