I'm developing a tool for masternode automization similar to https://gincoin.io .
I'm trying to figure out how to decode if transaction is viable for a masternode.
From what I know the transaction must meet the following criteria to be a viable masternode candidate:
- The send amount must be exactly as required for a masternode per coin specification (for example exactly 1000.0 coins)
- None of those coins should be spent
- The transaction must be verified by enough peers
- Send and return address must match (must be a transaction to yourself)
From what I have gather getrawtransaction
call with txindex
enabled client is the only tool that provide accurate info on transaction, as gettransaction
is for wallet's internal use only.
So for example
I made the following transaction to myself at yPNYZoqKHMM49z1JzvCFAzrSTJpKmVmMio
receive address:
When I execute
$ dash-cli -testnet getrawtransaction dd4011a1892a49d9109c299cad6a902ea60aff5a76f49c7d43f1a28861d0a8d3 1
Returns the following info on the transaction details:
{
"hex": "01000000027d0511a068dc2b978f840d761c64760307c3eea44eecddbac3d458ed4848b8af000000006a47304402206d040ff0825fa11af1fa497f9e9ca52218b7576e61679ce73475a899d1d005420220572d6104cab20d1abc77eec0e8d50b78f20ad0aaa5d7720878664a38af90a0c00121030613391de767cf19d8dd1fd3275ce661f5ff1e341e0130d7ade004b4a37c0607feffffff7d0511a068dc2b978f840d761c64760307c3eea44eecddbac3d458ed4848b8af010000006a4730440220296f0c7f8a8a538613e10644454c2146cc978509963a5bfe2211c8126c19c03502207c3310582e08585a2e9329cd14687589da58c3ff730ad75a0bba06a846de0caf01210393b4249c1d422cda439e9629ecb80c23aa0586082c5473ae509c94b395d0d061feffffff028b9e7851000000001976a9146be245a75e9e2b49f3392d260a06249de2396d3388ac00e87648170000001976a914217e65d7d68fc632e1ae63b7536c900021fa927288acd93b0300",
"txid": "dd4011a1892a49d9109c299cad6a902ea60aff5a76f49c7d43f1a28861d0a8d3",
"size": 372,
"version": 1,
"locktime": 211929,
"vin": [
{
"txid": "afb84848ed58d4c3baddec4ea4eec3070376641c760d848f972bdc68a011057d",
"vout": 0,
"scriptSig": {
"asm": "304402206d040ff0825fa11af1fa497f9e9ca52218b7576e61679ce73475a899d1d005420220572d6104cab20d1abc77eec0e8d50b78f20ad0aaa5d7720878664a38af90a0c0[ALL] 030613391de767cf19d8dd1fd3275ce661f5ff1e341e0130d7ade004b4a37c0607",
"hex": "47304402206d040ff0825fa11af1fa497f9e9ca52218b7576e61679ce73475a899d1d005420220572d6104cab20d1abc77eec0e8d50b78f20ad0aaa5d7720878664a38af90a0c00121030613391de767cf19d8dd1fd3275ce661f5ff1e341e0130d7ade004b4a37c0607"
},
"sequence": 4294967294
},
{
"txid": "afb84848ed58d4c3baddec4ea4eec3070376641c760d848f972bdc68a011057d",
"vout": 1,
"scriptSig": {
"asm": "30440220296f0c7f8a8a538613e10644454c2146cc978509963a5bfe2211c8126c19c03502207c3310582e08585a2e9329cd14687589da58c3ff730ad75a0bba06a846de0caf[ALL] 0393b4249c1d422cda439e9629ecb80c23aa0586082c5473ae509c94b395d0d061",
"hex": "4730440220296f0c7f8a8a538613e10644454c2146cc978509963a5bfe2211c8126c19c03502207c3310582e08585a2e9329cd14687589da58c3ff730ad75a0bba06a846de0caf01210393b4249c1d422cda439e9629ecb80c23aa0586082c5473ae509c94b395d0d061"
},
"sequence": 4294967294
}
],
"vout": [
{
"value": 13.66859403,
"valueSat": 1366859403,
"n": 0,
"scriptPubKey": {
"asm": "OP_DUP OP_HASH160 6be245a75e9e2b49f3392d260a06249de2396d33 OP_EQUALVERIFY OP_CHECKSIG",
"hex": "76a9146be245a75e9e2b49f3392d260a06249de2396d3388ac",
"reqSigs": 1,
"type": "pubkeyhash",
"addresses": [
"yW9tDPWry4F4Yoh2ejVpdvMtjawBpNq2jV"
]
}
},
{
"value": 1000.00000000,
"valueSat": 100000000000,
"n": 1,
"scriptPubKey": {
"asm": "OP_DUP OP_HASH160 217e65d7d68fc632e1ae63b7536c900021fa9272 OP_EQUALVERIFY OP_CHECKSIG",
"hex": "76a914217e65d7d68fc632e1ae63b7536c900021fa927288ac",
"reqSigs": 1,
"type": "pubkeyhash",
"addresses": [
"yPNYZoqKHMM49z1JzvCFAzrSTJpKmVmMio"
]
}
}
]
}
This vout
portion in particular confirms that exactly 1000.0 coins is sent to the address as requested yPNYZoqKHMM49z1JzvCFAzrSTJpKmVmMio
:
{
"value": 1000.00000000,
"valueSat": 100000000000,
"n": 1,
"scriptPubKey": {
"asm": "OP_DUP OP_HASH160 217e65d7d68fc632e1ae63b7536c900021fa9272 OP_EQUALVERIFY OP_CHECKSIG",
"hex": "76a914217e65d7d68fc632e1ae63b7536c900021fa927288ac",
"reqSigs": 1,
"type": "pubkeyhash",
"addresses": [
"yPNYZoqKHMM49z1JzvCFAzrSTJpKmVmMio"
]
}
}
But how do I check if that's a transaction yourself, and that none of those 1000 coins were spent?
NOTE This is not a specific cryptocurrency related, and should work on any generic rpc wallet client that's masternode enabled.