先日testnetで遊んでたらなぜか検証に失敗するらしいトランザクションができてしまい、ブロードキャストはできないしお金は吸い込まれちゃったしで泣きながら対応した時のお話。
状況
対象のトランザクション
{ "txid": "d194e9097320090b6f8d4a13c1a0f383f959a2c1d6b05b0d2812019f2ed12caa", "hash": "cd6502c67f9008174cc0be12b9b4ae56815786c214dd814a1f3e6c59b745c64d", "features": 1, "size": 258, "locktime": 187796, "vin": [ { "txid": "3b49b5afb9027dd910007424d59c6cd1ce457ab08edb3b521c75163e6eaef500", "vout": 1, "scriptSig": { "asm": "30440220535b78168ea744b4a2cd3829d9e2b04ada585d71618422b5a669bfa3baaa7a61022060743d1cf2b3627dd52dc9c870b841697ee2c93909966a9ffdbd4f6c412231d9[ALL] 0229f9333478d5e9a3c5e3a451383bfd27f124b4891e97af066060ca963a5acabd", "hex": "4730440220535b78168ea744b4a2cd3829d9e2b04ada585d71618422b5a669bfa3baaa7a61022060743d1cf2b3627dd52dc9c870b841697ee2c93909966a9ffdbd4f6c412231d901210229f9333478d5e9a3c5e3a451383bfd27f124b4891e97af066060ca963a5acabd" }, "sequence": 4294967294 } ], "vout": [ { "token": "c315e9dced5401fe0ae1caaec69ea382440b0dfdbac7803495b8d58f92fc7d62ac", "value": 1, "n": 0, "scriptPubKey": { "asm": "c315e9dced5401fe0ae1caaec69ea382440b0dfdbac7803495b8d58f92fc7d62ac OP_COLOR OP_HASH160 08d01c28e28e00f0d59ef05b84df8fb6445e87e3 OP_EQUAL", "hex": "21c315e9dced5401fe0ae1caaec69ea382440b0dfdbac7803495b8d58f92fc7d62acbca91408d01c28e28e00f0d59ef05b84df8fb6445e87e387", "reqSigs": 1, "type": "coloredscripthash", "addresses": [ "4ZvKgQcct4Ec2RLkWHKPXe4NqY8WVjDKy2Gd1vxaXGKCyA2CeNQgA47bKkr8nYtd2LSfCiXm3rndbmX" ] } }, { "token": "TPC", "value": 0.99999157, "n": 1, "scriptPubKey": { "asm": "OP_DUP OP_HASH160 9a101bc5c0daf28b73c4697a7eff19e131eca06a OP_EQUALVERIFY OP_CHECKSIG", "hex": "76a9149a101bc5c0daf28b73c4697a7eff19e131eca06a88ac", "reqSigs": 1, "type": "pubkeyhash", "addresses": [ "1F3cMnBzTMQuV65MSf8xjFJfBsRWdnSsSY" ] } } ] }
これがいつまで経ってもブロックに取り込まれない
お金吸われちゃって無一文
$ tapyrus-cli listunspent [ ]
メモリプールを探そうにも空っぽ
$ tapyrus-cli getrawmempool [ ]
ブロックに取り込まれていないので getrawtransaction
は動かず
$ tapyrus-cli getrawtransaction d194e9097320090b6f8d4a13c1a0f383f959a2c1d6b05b0d2812019f2ed12caa error code: -5 error message: No such mempool or blockchain transaction. Use gettransaction for wallet transactions.
言われた通り gettransaction
して hexstring
を入手し
$ tapyrus-cli gettransaction d194e9097320090b6f8d4a13c1a0f383f959a2c1d6b05b0d2812019f2ed12caa { "token": "TPC", "amount": 0.00000000, "fee": -0.00000258, "confirmations": 0, "trusted": false, "txid": "d194e9097320090b6f8d4a13c1a0f383f959a2c1d6b05b0d2812019f2ed12caa", "walletconflicts": [ ], "time": 1649761148, "timereceived": 1649761148, "bip125-replaceable": "unknown", "details": [ { "address": "4ZvKgQcct4Ec2RLkWHKPXe4NqY8WVjDKy2Gd1vxaXGKCyA2CeNQgA47bKkr8nYtd2LSfCiXm3rndbmX", "category": "receive", "token": "c315e9dced5401fe0ae1caaec69ea382440b0dfdbac7803495b8d58f92fc7d62ac", "amount": 1, "vout": 0 } ], "hex": "010000000100f5ae6e3e16751c523bdb8eb07a45ced16c9cd524740010d97d02b9afb5493b010000006a4730440220535b78168ea744b4a2cd3829d9e2b04ada585d71618422b5a669bfa3baaa7a61022060743d1cf2b3627dd52dc9c870b841697ee2c93909966a9ffdbd4f6c412231d901210229f9333478d5e9a3c5e3a451383bfd27f124b4891e97af066060ca963a5acabdfeffffff0201000000000000003a21c315e9dced5401fe0ae1caaec69ea382440b0dfdbac7803495b8d58f92fc7d62acbca91408d01c28e28e00f0d59ef05b84df8fb6445e87e387b5ddf505000000001976a9149a101bc5c0daf28b73c4697a7eff19e131eca06a88ac94dd0200" }
それを手動でブロードキャストしようとするも怒られ
$ tapyrus-cli -conf=/etc/tapyrus/tapyrus.conf sendrawtransaction 010000000100f5ae6e3e16751c523bdb8eb07a45ced16c9cd524740010d97d02b9afb5493b010000006a4730440220535b78168ea744b4a2cd3829d9e2b04ada585d71618422b5a669bfa3baaa7a61022060743d1cf2b3627dd52dc9c870b841697ee2c93909966a9ffdbd4f6c412231d901210229f9333478d5e9a3c5e3a451383bfd27f124b4891e97af066060ca963a5acabdfeffffff0201000000000000003a21c315e9dced5401fe0ae1caaec69ea382440b0dfdbac7803495b8d58f92fc7d62acbca91408d01c28e28e00f0d59ef05b84df8fb6445e87e387b5ddf505000000001976a9149a101bc5c0daf28b73c4697a7eff19e131eca06a88ac94dd0200 error code: -26 error message: bad-txns-token-insufficient (code 66)
つまり検証の失敗事由は”bad-txns-token-insufficient”
メモリプールでのテスト検証にも失敗し
$ tapyrus-cli testmempoolaccept '["010000000100f5ae6e3e16751c523bdb8eb07a45ced16c9cd524740010d97d02b9afb5493b010000006a4730440220535b78168ea744b4a2cd3829d9e2b04ada585d71618422b5a669bfa3baaa7a61022060743d1cf2b3627dd52dc9c870b841697ee2c93909966a9ffdbd4f6c412231d901210229f9333478d5e9a3c5e3a451383bfd27f124b4891e97af066060ca963a5acabdfeffffff0201000000000000003a21c315e9dced5401fe0ae1caaec69ea382440b0dfdbac7803495b8d58f92fc7d62acbca91408d01c28e28e00f0d59ef05b84df8fb6445e87e387b5ddf505000000001976a9149a101bc5c0daf28b73c4697a7eff19e131eca06a88ac94dd0200"]' [ { "txid": "d194e9097320090b6f8d4a13c1a0f383f959a2c1d6b05b0d2812019f2ed12caa", "allowed": false, "reject-reason": "66: bad-txns-token-insufficient" } ]
途方に暮れながらなんとかしてこのトランザクションを破棄するコマンドを探していたらドンピシャのコマンドを見つけた
$ tapyrus-cli help ... == Wallet == abandontransaction "txid" ...
これじゃん
解決
実行してみる
$ tapyrus-cli abandontransaction d194e9097320090b6f8d4a13c1a0f383f959a2c1d6b05b0d2812019f2ed12caa
出力は無し
すると
$ tapyrus-cli listunspent [ { "txid": "3b49b5afb9027dd910007424d59c6cd1ce457ab08edb3b521c75163e6eaef500", "vout": 1, "address": "123iMA5vDJgo89NkTosfKqhQXArL3p1Mcm", "token": "TPC", "amount": 0.99999415, "scriptPubKey": "76a9140b7b790f099e87ea17828b64fc433134ffaa253d88ac", "confirmations": 22, "spendable": true, "solvable": true, "safe": true } ]
帰ってきた😭
ただ何が原因だったのかいまいちよく分からないので再現して原因を探りたい...