bitcoin-ruby
bitcoin-ruby copied to clipboard
litecoin
I am having difficulty generating a new transaction from the example because the data returned by either an api or decoding the transaction from my own node is insufficiently mapped to how the Bitcoin::P::Tx.from_json library expects the values to be.
Is there more documentation w/ regards to litecoin over bitcoin? I made sure Bitcoin.network = :litecoin
. I've also shimed the json to (hopefully) match the expected values of Bitcoin::P::TxIn/Out but the hashes aren't matching.
This is the litecoin transaction from my node:
{
"txid": "6a2502f319f0b8c8a2ef2bdfd61b3a9d6592c29012e4cd13f86bcaa6670c9013",
"hash": "28a5991b72d85001162f0359df6f58e75f8c1b5daa839a7a88722fe82ef2a8fd",
"version": 1,
"size": 224,
"vsize": 142,
"locktime": 0,
"vin": [
{
"txid": "0bbcd2c9b9b4f08aceb9c067db6f2380504b5cfc254c399cd8c93dc9282c83f5",
"vout": 0,
"scriptSig": {
"asm": "",
"hex": ""
},
"txinwitness": [
"3045022100d8c20b038335bfd005d8045b1d3691cba622f57744d32f9df3eaa9635688653e02200bf7bcddf0cb6f0e90d9c0d407eeef74f7d88cefbeec04f55676b858e84241ea01",
"034b32d8a5e0855204e9184e48e8a387daa18c5a84ff11079326633ce27e636765"
],
"sequence": 4294967295
}
],
"vout": [
{
"value": 0.10043107,
"n": 0,
"scriptPubKey": {
"asm": "OP_HASH160 bcd2674d44f22b9a641e1023824dbaac8fe3156c OP_EQUAL",
"hex": "a914bcd2674d44f22b9a641e1023824dbaac8fe3156c87",
"reqSigs": 1,
"type": "scripthash",
"addresses": [
"MR7ZKb28eJm5k2sPUqHmTcVgszYcHBmJq5"
]
}
},
{
"value": 0.00385193,
"n": 1,
"scriptPubKey": {
"asm": "0 776b9858a41dfbd58f7ae144e74d69e4650625f0",
"hex": "0014776b9858a41dfbd58f7ae144e74d69e4650625f0",
"type": "witness_v0_keyhash"
}
}
]
}
is from https://live.blockcypher.com/ltc/decodetx/
{
"addresses": [
"ltc1q5qammthmtfxug0gj4dyfgk034sf78vesk0029v",
"3JuR1hcAhBuewXbVNxJRdyFHZHxAGaxHWv",
"ltc1qwa4esk9yrhaatrm6u9zwwntfu3jsvf0s2l5wl0"
],
"block_height": -1,
"block_index": -1,
"confirmations": 0,
"double_spend": false,
"fees": 426,
"hash": "6a2502f319f0b8c8a2ef2bdfd61b3a9d6592c29012e4cd13f86bcaa6670c9013",
"inputs": [
{
"addresses": [
"ltc1q5qammthmtfxug0gj4dyfgk034sf78vesk0029v"
],
"age": 1704191,
"output_index": 0,
"output_value": 10428726,
"prev_hash": "0bbcd2c9b9b4f08aceb9c067db6f2380504b5cfc254c399cd8c93dc9282c83f5",
"script_type": "pay-to-witness-pubkey-hash",
"sequence": 4294967295,
"witness": [
"3045022100d8c20b038335bfd005d8045b1d3691cba622f57744d32f9df3eaa9635688653e02200bf7bcddf0cb6f0e90d9c0d407eeef74f7d88cefbeec04f55676b858e84241ea01",
"034b32d8a5e0855204e9184e48e8a387daa18c5a84ff11079326633ce27e636765"
]
}
],
"outputs": [
{
"addresses": [
"3JuR1hcAhBuewXbVNxJRdyFHZHxAGaxHWv"
],
"script": "a914bcd2674d44f22b9a641e1023824dbaac8fe3156c87",
"script_type": "pay-to-script-hash",
"value": 10043107
},
{
"addresses": [
"ltc1qwa4esk9yrhaatrm6u9zwwntfu3jsvf0s2l5wl0"
],
"script": "0014776b9858a41dfbd58f7ae144e74d69e4650625f0",
"script_type": "pay-to-witness-pubkey-hash",
"value": 385193
}
],
"preference": "low",
"received": "2019-10-01T19:00:30.798180122Z",
"relayed_by": "34.201.46.179",
"size": 114,
"total": 10428300,
"ver": 1,
"vin_sz": 1,
"vout_sz": 2
}
The txid
of your code and "hash": "6a2502f319f0b8c8a2ef2bdfd61b3a9d6592c29012e4cd13f86bcaa6670c9013"
match.
https://live.blockcypher.com/ltc/decodetx/ looks like returns a hash that excludes the witness of Segwit, that is txid.