mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08:33 +00:00
[DEV-320] add decoupling related fields to wire tx (#134)
* [DEV-320] Add decoupling-related fields to wire.Tx * [DEV-320] Fix SerializeSize for MsgTx * [DEV-320] Fix indexers test * [DEV-320] Fix utils test * [DEV-320] Fix ffldb tests * [DEV-320] Fix mining tests * [DEV-320] fix txsort tests * [DEV-320] change default subnetwork id to 1 and remove payload for default subnetwork id * [DEV-320] Add msgtx serialization tests * [DEV-320] get rid of temp prints, and change error messages
This commit is contained in:
parent
fa8002a644
commit
4a6fd8fad1
@ -94,7 +94,7 @@ func TestHaveBlock(t *testing.T) {
|
||||
DAGParams: &dagconfig.SimNetParams,
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to setup chain instance: %v", err)
|
||||
t.Fatalf("Failed to setup DAG instance: %v", err)
|
||||
}
|
||||
defer teardownFunc()
|
||||
|
||||
@ -185,10 +185,10 @@ func TestHaveBlock(t *testing.T) {
|
||||
{hash: dagconfig.SimNetParams.GenesisHash.String(), want: true},
|
||||
|
||||
// Block 3b should be present (as a second child of Block 2).
|
||||
{hash: "2b31fe171eeadcaec5978add980ebb8108fd5d9082e870ff71744842e0dd01bb", want: true},
|
||||
{hash: "74e325a48f84020f3d36c07edf9cda95d93cff866ff8e8df5d2825d2ced6d28f", want: true},
|
||||
|
||||
// Block 100000 should be present (as an orphan).
|
||||
{hash: "64f3da4fe61edb33ad6dd5e857ebcfe296182a0c4aaef01e30b4032b94ec1620", want: true},
|
||||
{hash: "566ca0e828951be69df4b45b82b4eb9b593b712a0018a382cb75790f85810be3", want: true},
|
||||
|
||||
// Random hashes should not be available.
|
||||
{hash: "123", want: false},
|
||||
|
@ -68,7 +68,7 @@ func ExampleBlockDAG_ProcessBlock() {
|
||||
fmt.Printf("Block accepted. Is it an orphan?: %v", isOrphan)
|
||||
|
||||
// Output:
|
||||
// Failed to process block: already have block 000000f9fa27ce9258baefc92e485fc5744eae341554fd03f25e1e10baa8c9c3
|
||||
// Failed to process block: already have block 47c205482e0a2aa1f5503ec73ea0ffe5226f9d9357f037dcde79f75d85171634
|
||||
}
|
||||
|
||||
// This example demonstrates how to convert the compact "bits" in a block header
|
||||
|
@ -83,7 +83,8 @@ var (
|
||||
"c4f35504e51ec112de5c384df7ba0b8d578a" +
|
||||
"4c702b6bf11d5fac"),
|
||||
}},
|
||||
LockTime: 0,
|
||||
LockTime: 0,
|
||||
SubNetworkID: wire.SubNetworkDAGCoin,
|
||||
}},
|
||||
}
|
||||
)
|
||||
|
@ -107,21 +107,21 @@ var block1 = wire.MsgBlock{
|
||||
Version: 1,
|
||||
ParentHashes: []daghash.Hash{
|
||||
[32]byte{ // Make go vet happy.
|
||||
0x4a, 0xc1, 0x82, 0x2e, 0x43, 0x05, 0xea, 0x0c,
|
||||
0x4f, 0xcc, 0x77, 0x87, 0xae, 0x26, 0x48, 0x87,
|
||||
0x50, 0x13, 0xee, 0x2f, 0x55, 0xa7, 0x18, 0xa7,
|
||||
0x1e, 0xf2, 0xd8, 0x7c, 0xc1, 0x13, 0xac, 0x22,
|
||||
0x34, 0x16, 0x17, 0x85, 0x5d, 0xf7, 0x79, 0xde,
|
||||
0xdc, 0x37, 0xf0, 0x57, 0x93, 0x9d, 0x6f, 0x22,
|
||||
0xe5, 0xff, 0xa0, 0x3e, 0xc7, 0x3e, 0x50, 0xf5,
|
||||
0xa1, 0x2a, 0x0a, 0x2e, 0x48, 0x05, 0xc2, 0x47,
|
||||
},
|
||||
},
|
||||
MerkleRoot: daghash.Hash([32]byte{ // Make go vet happy.
|
||||
0xec, 0x37, 0x81, 0x75, 0x51, 0x79, 0x41, 0x34,
|
||||
0x3a, 0xae, 0x05, 0x48, 0x67, 0xfa, 0xdf, 0x84,
|
||||
0xef, 0x06, 0x5b, 0x93, 0x07, 0xa8, 0xc2, 0xb7,
|
||||
0x2a, 0x94, 0x07, 0x3b, 0x5f, 0xee, 0xb8, 0x6a,
|
||||
0x6c, 0x56, 0xa7, 0x7d, 0xfa, 0x18, 0x89, 0xdc,
|
||||
0x20, 0x60, 0x3f, 0x51, 0x32, 0xa8, 0xdc, 0x47,
|
||||
0x5f, 0x43, 0xb7, 0xe8, 0xae, 0x24, 0x22, 0x34,
|
||||
0x64, 0x91, 0xe7, 0xd5, 0xac, 0xc0, 0xed, 0x88,
|
||||
}),
|
||||
Timestamp: time.Unix(0x5bd58c4a, 0),
|
||||
Timestamp: time.Unix(0x5c238b71, 0),
|
||||
Bits: 0x207fffff,
|
||||
Nonce: 0xdffffffffffffffa,
|
||||
Nonce: 0x00000000,
|
||||
},
|
||||
Transactions: []*wire.MsgTx{
|
||||
{
|
||||
@ -150,7 +150,8 @@ var block1 = wire.MsgBlock{
|
||||
},
|
||||
},
|
||||
},
|
||||
LockTime: 0,
|
||||
LockTime: 0,
|
||||
SubNetworkID: wire.SubNetworkDAGCoin,
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -160,21 +161,21 @@ var block2 = wire.MsgBlock{
|
||||
Version: 1,
|
||||
ParentHashes: []daghash.Hash{
|
||||
[32]byte{ // Make go vet happy.
|
||||
0x42, 0xb9, 0x2c, 0xee, 0x3e, 0x3e, 0x35, 0x02,
|
||||
0xf5, 0x8d, 0xd2, 0xc8, 0xff, 0x61, 0xe3, 0x44,
|
||||
0x59, 0xb2, 0x5d, 0x72, 0x10, 0x29, 0x62, 0x58,
|
||||
0x3f, 0xc9, 0x41, 0xe2, 0xcd, 0xa9, 0x05, 0x11,
|
||||
0x69, 0xe9, 0xd1, 0xa2, 0xd0, 0x5f, 0x35, 0x39,
|
||||
0x6b, 0xa7, 0x1d, 0xeb, 0x97, 0x33, 0x7f, 0xcf,
|
||||
0xa1, 0xa8, 0xc5, 0x1f, 0x31, 0x82, 0x09, 0x62,
|
||||
0x79, 0xb3, 0xf9, 0xd6, 0x66, 0x3f, 0xd7, 0x45,
|
||||
},
|
||||
},
|
||||
MerkleRoot: daghash.Hash([32]byte{ // Make go vet happy.
|
||||
0x3e, 0x89, 0x5f, 0xb4, 0xa8, 0x2f, 0x64, 0xb9,
|
||||
0xe7, 0x1d, 0x5d, 0xce, 0x41, 0x4a, 0xb0, 0x36,
|
||||
0x4e, 0xd0, 0x4b, 0xfc, 0x0c, 0xe1, 0x82, 0xfc,
|
||||
0x51, 0x0d, 0x03, 0x7b, 0x8c, 0xdd, 0x3e, 0x49,
|
||||
0x29, 0xdc, 0xa7, 0x2b, 0x14, 0xfb, 0x5b, 0xe4,
|
||||
0x3c, 0x7c, 0x91, 0x3c, 0x54, 0x7c, 0xbe, 0x20,
|
||||
0x98, 0xe8, 0xc6, 0x01, 0x65, 0x59, 0x02, 0xa5,
|
||||
0xa2, 0xf5, 0xf1, 0x9f, 0x3b, 0x3f, 0x28, 0x3c,
|
||||
}),
|
||||
Timestamp: time.Unix(0x5bd58c4b, 0),
|
||||
Timestamp: time.Unix(0x5c238b72, 0),
|
||||
Bits: 0x207fffff,
|
||||
Nonce: 0x9ffffffffffffffb,
|
||||
Nonce: 0x2000000000000001,
|
||||
},
|
||||
Transactions: []*wire.MsgTx{
|
||||
{
|
||||
@ -203,7 +204,8 @@ var block2 = wire.MsgBlock{
|
||||
},
|
||||
},
|
||||
},
|
||||
LockTime: 0,
|
||||
LockTime: 0,
|
||||
SubNetworkID: wire.SubNetworkDAGCoin,
|
||||
},
|
||||
{
|
||||
Version: 1,
|
||||
@ -211,28 +213,28 @@ var block2 = wire.MsgBlock{
|
||||
{
|
||||
PreviousOutPoint: wire.OutPoint{
|
||||
Hash: daghash.Hash{
|
||||
0xec, 0x37, 0x81, 0x75, 0x51, 0x79, 0x41, 0x34,
|
||||
0x3a, 0xae, 0x05, 0x48, 0x67, 0xfa, 0xdf, 0x84,
|
||||
0xef, 0x06, 0x5b, 0x93, 0x07, 0xa8, 0xc2, 0xb7,
|
||||
0x2a, 0x94, 0x07, 0x3b, 0x5f, 0xee, 0xb8, 0x6a,
|
||||
0x6c, 0x56, 0xa7, 0x7d, 0xfa, 0x18, 0x89, 0xdc,
|
||||
0x20, 0x60, 0x3f, 0x51, 0x32, 0xa8, 0xdc, 0x47,
|
||||
0x5f, 0x43, 0xb7, 0xe8, 0xae, 0x24, 0x22, 0x34,
|
||||
0x64, 0x91, 0xe7, 0xd5, 0xac, 0xc0, 0xed, 0x88,
|
||||
},
|
||||
Index: 0,
|
||||
},
|
||||
SignatureScript: []byte{
|
||||
0x47, 0x30, 0x44, 0x02, 0x20, 0x5d, 0xca, 0x41,
|
||||
0xb0, 0x73, 0x9e, 0xba, 0x0c, 0xba, 0x59, 0xdd,
|
||||
0xb5, 0x6a, 0x6e, 0xd2, 0xd2, 0x36, 0x61, 0xa5,
|
||||
0xa0, 0x5c, 0xb5, 0x2b, 0xee, 0x5f, 0x30, 0x62,
|
||||
0x72, 0xb3, 0x26, 0xa2, 0xdb, 0x02, 0x20, 0x0d,
|
||||
0xc5, 0x22, 0xd8, 0x88, 0x5a, 0xf7, 0xef, 0x60,
|
||||
0xa6, 0xd9, 0x5c, 0x7a, 0x44, 0x96, 0xfc, 0x14,
|
||||
0x66, 0x74, 0xda, 0x2b, 0x6c, 0x99, 0x2c, 0x56,
|
||||
0x34, 0x3d, 0x64, 0xdf, 0xc2, 0x36, 0xe8, 0x01,
|
||||
0x21, 0x02, 0xa6, 0x73, 0x63, 0x8c, 0xb9, 0x58,
|
||||
0x7c, 0xb6, 0x8e, 0xa0, 0x8d, 0xbe, 0xf6, 0x85,
|
||||
0xc6, 0xf2, 0xd2, 0xa7, 0x51, 0xa8, 0xb3, 0xc6,
|
||||
0xf2, 0xa7, 0xe9, 0xa4, 0x99, 0x9e, 0x6e, 0x4b,
|
||||
0xfa, 0xf5,
|
||||
0x46, 0x30, 0x43, 0x02, 0x1f, 0x56, 0x0a, 0xfa,
|
||||
0x84, 0xc7, 0x80, 0xe1, 0x56, 0xe0, 0xec, 0x18,
|
||||
0xe7, 0xd7, 0x02, 0x87, 0x1f, 0x22, 0x62, 0xda,
|
||||
0xfa, 0x33, 0x82, 0xfc, 0x1d, 0x01, 0x7a, 0x0e,
|
||||
0xa5, 0x5f, 0x4e, 0xce, 0x02, 0x20, 0x6d, 0x1f,
|
||||
0xaf, 0xca, 0x91, 0x33, 0x8d, 0xfb, 0xb7, 0xa2,
|
||||
0x40, 0xf9, 0x4f, 0x3c, 0x04, 0xc9, 0x47, 0x29,
|
||||
0x6a, 0x7f, 0x45, 0x62, 0x0a, 0x2a, 0x7d, 0x93,
|
||||
0x7b, 0xe2, 0xc9, 0xba, 0x15, 0xb3, 0x01, 0x21,
|
||||
0x02, 0xa6, 0x73, 0x63, 0x8c, 0xb9, 0x58, 0x7c,
|
||||
0xb6, 0x8e, 0xa0, 0x8d, 0xbe, 0xf6, 0x85, 0xc6,
|
||||
0xf2, 0xd2, 0xa7, 0x51, 0xa8, 0xb3, 0xc6, 0xf2,
|
||||
0xa7, 0xe9, 0xa4, 0x99, 0x9e, 0x6e, 0x4b, 0xfa,
|
||||
0xf5,
|
||||
},
|
||||
Sequence: math.MaxUint64,
|
||||
},
|
||||
@ -248,34 +250,35 @@ var block2 = wire.MsgBlock{
|
||||
},
|
||||
},
|
||||
},
|
||||
LockTime: 0,
|
||||
LockTime: 0,
|
||||
SubNetworkID: wire.SubNetworkDAGCoin,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
var block3Tx *wire.MsgTx = &wire.MsgTx{
|
||||
var block3Tx = &wire.MsgTx{
|
||||
Version: 1,
|
||||
TxIn: []*wire.TxIn{
|
||||
{
|
||||
PreviousOutPoint: wire.OutPoint{
|
||||
Hash: daghash.Hash{
|
||||
0x69, 0x11, 0xbd, 0x7e, 0x46, 0x5e, 0xe8, 0xf7,
|
||||
0xbe, 0x80, 0xb0, 0x21, 0x6a, 0xc8, 0xb4, 0xea,
|
||||
0xef, 0xfa, 0x6a, 0x34, 0x75, 0x6e, 0xb5, 0x96,
|
||||
0xd9, 0x3b, 0xe2, 0x6a, 0xd6, 0x49, 0xac, 0x6e,
|
||||
0x99, 0x30, 0x0c, 0x6e, 0xad, 0x5c, 0x9c, 0xcf,
|
||||
0xfc, 0xcb, 0x62, 0xfd, 0x39, 0xe3, 0xc1, 0x7e,
|
||||
0x87, 0x17, 0xec, 0x9e, 0x7b, 0xc7, 0x81, 0xe0,
|
||||
0x8f, 0x15, 0x85, 0xcb, 0x6d, 0x54, 0x74, 0x3e,
|
||||
},
|
||||
Index: 0,
|
||||
},
|
||||
SignatureScript: []byte{
|
||||
0x48, 0x30, 0x45, 0x02, 0x21, 0x00, 0xea, 0xa8,
|
||||
0xa5, 0x8b, 0x2d, 0xeb, 0x15, 0xc1, 0x18, 0x79,
|
||||
0xa4, 0xad, 0xc3, 0xde, 0x57, 0x09, 0xac, 0xdb,
|
||||
0x16, 0x16, 0x9f, 0x07, 0xe8, 0x7d, 0xbe, 0xf1,
|
||||
0x4b, 0xaa, 0xd3, 0x76, 0xb4, 0x87, 0x02, 0x20,
|
||||
0x03, 0xb3, 0xee, 0xc8, 0x9f, 0x87, 0x18, 0xee,
|
||||
0xf3, 0xc3, 0x29, 0x29, 0x57, 0xb9, 0x93, 0x95,
|
||||
0x4a, 0xe9, 0x49, 0x74, 0x90, 0xa1, 0x5b, 0xae,
|
||||
0x49, 0x16, 0xa9, 0x3e, 0xb8, 0xf0, 0xf9, 0x6b,
|
||||
0x48, 0x30, 0x45, 0x02, 0x21, 0x00, 0x91, 0xa3,
|
||||
0xb4, 0x99, 0x57, 0xb2, 0x53, 0x2f, 0x7f, 0xaf,
|
||||
0xb6, 0x4d, 0x9d, 0x7b, 0x1b, 0xa2, 0x41, 0x03,
|
||||
0x1a, 0xe5, 0xfd, 0x4d, 0xe1, 0x5a, 0x7e, 0x9f,
|
||||
0xe3, 0xdd, 0x44, 0xb8, 0x62, 0x13, 0x02, 0x20,
|
||||
0x7a, 0xba, 0x9a, 0xe6, 0xa5, 0x81, 0x43, 0xb9,
|
||||
0x05, 0x66, 0xc1, 0xa3, 0x79, 0xad, 0xf0, 0xf4,
|
||||
0xb9, 0xfe, 0x28, 0x13, 0x35, 0xd6, 0x84, 0x95,
|
||||
0x08, 0xd0, 0xaa, 0x1d, 0xb7, 0x5b, 0x88, 0x4c,
|
||||
0x01, 0x21, 0x02, 0xa6, 0x73, 0x63, 0x8c, 0xb9,
|
||||
0x58, 0x7c, 0xb6, 0x8e, 0xa0, 0x8d, 0xbe, 0xf6,
|
||||
0x85, 0xc6, 0xf2, 0xd2, 0xa7, 0x51, 0xa8, 0xb3,
|
||||
@ -296,7 +299,8 @@ var block3Tx *wire.MsgTx = &wire.MsgTx{
|
||||
},
|
||||
},
|
||||
},
|
||||
LockTime: 0,
|
||||
LockTime: 0,
|
||||
SubNetworkID: wire.SubNetworkDAGCoin,
|
||||
}
|
||||
|
||||
var block3 = wire.MsgBlock{
|
||||
@ -304,21 +308,21 @@ var block3 = wire.MsgBlock{
|
||||
Version: 1,
|
||||
ParentHashes: []daghash.Hash{
|
||||
[32]byte{ // Make go vet happy.
|
||||
0x8b, 0xdf, 0xd1, 0x48, 0xef, 0xf5, 0x2b, 0x5e,
|
||||
0xfe, 0x26, 0xba, 0x37, 0xcb, 0x23, 0x0d, 0x41,
|
||||
0x24, 0x80, 0xfe, 0x9a, 0x38, 0x90, 0xb9, 0xd3,
|
||||
0x07, 0x30, 0xcc, 0xa0, 0x4f, 0x4e, 0xf1, 0x02,
|
||||
0x96, 0x2d, 0x1d, 0x2b, 0xc2, 0xf9, 0x30, 0x43,
|
||||
0x88, 0x23, 0xdb, 0x75, 0x73, 0x43, 0xb8, 0xb6,
|
||||
0x76, 0x34, 0x42, 0x55, 0x8f, 0x44, 0x2a, 0x6f,
|
||||
0xb1, 0xac, 0x7e, 0x9b, 0x1f, 0x9f, 0x00, 0x19,
|
||||
},
|
||||
},
|
||||
MerkleRoot: daghash.Hash([32]byte{ // Make go vet happy.
|
||||
0x24, 0x0f, 0x21, 0x89, 0x94, 0xd1, 0x77, 0x32,
|
||||
0xff, 0x5d, 0xb4, 0xe9, 0x11, 0xd2, 0x74, 0xc9,
|
||||
0x0f, 0x0c, 0xb7, 0xe5, 0x16, 0xf6, 0xca, 0x63,
|
||||
0xac, 0xaa, 0x6c, 0x23, 0x42, 0xe9, 0xd5, 0x58,
|
||||
0x58, 0xbd, 0x06, 0x58, 0x0a, 0xab, 0x32, 0x10,
|
||||
0x97, 0x5c, 0xc6, 0x97, 0xb0, 0xde, 0xb9, 0xe2,
|
||||
0xa6, 0x21, 0x67, 0xe5, 0x2f, 0xa3, 0xc5, 0xb2,
|
||||
0xba, 0x8f, 0xd3, 0xc7, 0x4c, 0x18, 0x87, 0xc5,
|
||||
}),
|
||||
Timestamp: time.Unix(0x5bd58c4c, 0),
|
||||
Timestamp: time.Unix(0x5c238b73, 0),
|
||||
Bits: 0x207fffff,
|
||||
Nonce: 0x7ffffffffffffffc,
|
||||
Nonce: 0xdffffffffffffff9,
|
||||
},
|
||||
Transactions: []*wire.MsgTx{
|
||||
{
|
||||
@ -347,7 +351,8 @@ var block3 = wire.MsgBlock{
|
||||
},
|
||||
},
|
||||
},
|
||||
LockTime: 0,
|
||||
LockTime: 0,
|
||||
SubNetworkID: wire.SubNetworkDAGCoin,
|
||||
},
|
||||
block3Tx,
|
||||
},
|
||||
@ -358,19 +363,19 @@ var block3A = wire.MsgBlock{
|
||||
Version: 1,
|
||||
ParentHashes: []daghash.Hash{
|
||||
[32]byte{ // Make go vet happy.
|
||||
0x8b, 0xdf, 0xd1, 0x48, 0xef, 0xf5, 0x2b, 0x5e,
|
||||
0xfe, 0x26, 0xba, 0x37, 0xcb, 0x23, 0x0d, 0x41,
|
||||
0x24, 0x80, 0xfe, 0x9a, 0x38, 0x90, 0xb9, 0xd3,
|
||||
0x07, 0x30, 0xcc, 0xa0, 0x4f, 0x4e, 0xf1, 0x02,
|
||||
0x96, 0x2d, 0x1d, 0x2b, 0xc2, 0xf9, 0x30, 0x43,
|
||||
0x88, 0x23, 0xdb, 0x75, 0x73, 0x43, 0xb8, 0xb6,
|
||||
0x76, 0x34, 0x42, 0x55, 0x8f, 0x44, 0x2a, 0x6f,
|
||||
0xb1, 0xac, 0x7e, 0x9b, 0x1f, 0x9f, 0x00, 0x19,
|
||||
},
|
||||
},
|
||||
MerkleRoot: daghash.Hash([32]byte{ // Make go vet happy.
|
||||
0x4b, 0xd6, 0xbf, 0x21, 0xa0, 0x62, 0x77, 0xb5,
|
||||
0xc0, 0xd3, 0x3b, 0x31, 0x9d, 0x30, 0x9b, 0x89,
|
||||
0x93, 0x75, 0x50, 0xdb, 0x3b, 0x87, 0x23, 0x67,
|
||||
0x2f, 0xeb, 0xf9, 0xf2, 0x1b, 0x63, 0x5f, 0x1c,
|
||||
0xd3, 0x95, 0x8a, 0x56, 0xfe, 0x89, 0x86, 0x9f,
|
||||
0x47, 0x80, 0x9b, 0xea, 0x51, 0xec, 0x2b, 0x7d,
|
||||
0x76, 0xd5, 0x15, 0xde, 0x98, 0xad, 0x5d, 0x6e,
|
||||
0x79, 0xf5, 0xa4, 0x9b, 0x1b, 0x0c, 0xfa, 0x9b,
|
||||
}),
|
||||
Timestamp: time.Unix(0x5bd58c4c, 0),
|
||||
Timestamp: time.Unix(0x5c238b73, 0),
|
||||
Bits: 0x207fffff,
|
||||
Nonce: 0xdffffffffffffff9,
|
||||
},
|
||||
@ -401,7 +406,8 @@ var block3A = wire.MsgBlock{
|
||||
},
|
||||
},
|
||||
},
|
||||
LockTime: 0,
|
||||
LockTime: 0,
|
||||
SubNetworkID: wire.SubNetworkDAGCoin,
|
||||
},
|
||||
block3Tx,
|
||||
},
|
||||
@ -412,21 +418,21 @@ var block4 = wire.MsgBlock{
|
||||
Version: 1,
|
||||
ParentHashes: []daghash.Hash{
|
||||
[32]byte{ // Make go vet happy.
|
||||
0xde, 0xe3, 0x62, 0x5f, 0x0c, 0x98, 0x26, 0x5f,
|
||||
0x9b, 0x3e, 0xb1, 0xd9, 0x32, 0x0a, 0x84, 0xb3,
|
||||
0xe1, 0xbe, 0xe2, 0xb7, 0x8e, 0x4a, 0xfb, 0x97,
|
||||
0x7a, 0x53, 0x32, 0xff, 0x32, 0x17, 0xfc, 0x57,
|
||||
0x4c, 0xfb, 0xcd, 0x2b, 0x0f, 0x3c, 0xa3, 0x61,
|
||||
0x82, 0xce, 0x34, 0x39, 0x79, 0x0d, 0x22, 0x3b,
|
||||
0x94, 0xdc, 0x7b, 0x66, 0xf8, 0x62, 0xc7, 0xb2,
|
||||
0xd0, 0xfc, 0xb4, 0xf3, 0xc0, 0x7c, 0xa3, 0x63,
|
||||
},
|
||||
},
|
||||
MerkleRoot: daghash.Hash([32]byte{ // Make go vet happy.
|
||||
0xe1, 0x13, 0x4a, 0xd8, 0xd5, 0x43, 0x33, 0x95,
|
||||
0x55, 0x19, 0x00, 0xaf, 0x13, 0x3f, 0xd6, 0x3a,
|
||||
0x63, 0x98, 0x50, 0x61, 0xfc, 0x02, 0x2c, 0x44,
|
||||
0x1b, 0x0e, 0x74, 0x7d, 0x5c, 0x19, 0x58, 0xb4,
|
||||
0xe0, 0x32, 0x30, 0x4d, 0x53, 0x1d, 0xd4, 0xe0,
|
||||
0xe1, 0xc7, 0x20, 0xf8, 0x28, 0x86, 0x45, 0x9f,
|
||||
0x5d, 0x42, 0x1f, 0x2a, 0xb5, 0xcc, 0x62, 0x7f,
|
||||
0xe7, 0xf2, 0xdd, 0x22, 0x64, 0x7c, 0xc4, 0x66,
|
||||
}),
|
||||
Timestamp: time.Unix(0x5bd58c4d, 0),
|
||||
Timestamp: time.Unix(0x5c238b74, 0),
|
||||
Bits: 0x207fffff,
|
||||
Nonce: 0xdffffffffffffffa,
|
||||
Nonce: 0xdffffffffffffffb,
|
||||
},
|
||||
Transactions: []*wire.MsgTx{
|
||||
{
|
||||
@ -455,7 +461,8 @@ var block4 = wire.MsgBlock{
|
||||
},
|
||||
},
|
||||
},
|
||||
LockTime: 0,
|
||||
LockTime: 0,
|
||||
SubNetworkID: wire.SubNetworkDAGCoin,
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -465,19 +472,27 @@ var block5 = wire.MsgBlock{
|
||||
Version: 1,
|
||||
ParentHashes: []daghash.Hash{
|
||||
[32]byte{ // Make go vet happy.
|
||||
0xfd, 0x96, 0x3c, 0xfb, 0xed, 0x5a, 0xeb, 0xdb, 0x3d, 0x8e, 0xe9, 0x53, 0xf1, 0xe6, 0xad, 0x12, 0x21, 0x02, 0x55, 0x62, 0xbc, 0x2e, 0x52, 0xee, 0xb9, 0xd0, 0x60, 0xda, 0xd6, 0x4a, 0x20, 0x5a},
|
||||
0x03, 0x28, 0xad, 0x11, 0xe6, 0x8f, 0x48, 0x33,
|
||||
0x5c, 0xa8, 0xbb, 0x8c, 0x29, 0xde, 0x43, 0xd5,
|
||||
0x70, 0x8b, 0xbd, 0x1e, 0x61, 0x9d, 0xc8, 0x7d,
|
||||
0xc5, 0x52, 0x86, 0x26, 0x6b, 0x68, 0xec, 0x1f,
|
||||
},
|
||||
[32]byte{ // Make go vet happy.
|
||||
0xec, 0x42, 0x2c, 0x0c, 0x8c, 0x94, 0x50, 0x17, 0x85, 0xbb, 0x8c, 0xaf, 0x72, 0xd9, 0x39, 0x28, 0x26, 0xaa, 0x42, 0x8d, 0xd5, 0x09, 0xa2, 0xb6, 0xa6, 0x8c, 0x4e, 0x85, 0x72, 0x44, 0xd5, 0x70},
|
||||
0xcf, 0xfd, 0x63, 0x11, 0x72, 0xb7, 0xdc, 0x80,
|
||||
0x59, 0xd0, 0x35, 0x31, 0xed, 0x03, 0x89, 0x3a,
|
||||
0xe9, 0x9b, 0x74, 0xee, 0x86, 0xad, 0x3c, 0x4e,
|
||||
0x0b, 0x08, 0x46, 0xaa, 0x39, 0x30, 0xfa, 0x63,
|
||||
},
|
||||
},
|
||||
MerkleRoot: daghash.Hash([32]byte{ // Make go vet happy.
|
||||
0x77, 0xc7, 0x09, 0x46, 0x0f, 0x81, 0x37, 0xca,
|
||||
0xf5, 0xec, 0xa5, 0xae, 0x4c, 0xad, 0x65, 0xc5,
|
||||
0xdd, 0x73, 0x4f, 0xb5, 0xcf, 0x04, 0x20, 0x38,
|
||||
0x29, 0x10, 0x5b, 0x66, 0xfe, 0x15, 0x8a, 0xfb,
|
||||
0x8e, 0xb2, 0xf8, 0x31, 0xec, 0x11, 0xc2, 0x22,
|
||||
0xd1, 0x31, 0x47, 0xf0, 0xbb, 0x48, 0x74, 0xce,
|
||||
0x4a, 0x39, 0x25, 0x99, 0xa7, 0x1c, 0x8c, 0x83,
|
||||
0x98, 0x8d, 0x66, 0xc5, 0x94, 0xa9, 0xf1, 0x50,
|
||||
}),
|
||||
Timestamp: time.Unix(0x5bd58c4e, 0),
|
||||
Timestamp: time.Unix(0x5c238b75, 0),
|
||||
Bits: 0x207fffff,
|
||||
Nonce: 4,
|
||||
Nonce: 0xdffffffffffffffa,
|
||||
},
|
||||
Transactions: []*wire.MsgTx{
|
||||
{
|
||||
@ -506,7 +521,8 @@ var block5 = wire.MsgBlock{
|
||||
},
|
||||
},
|
||||
},
|
||||
LockTime: 0,
|
||||
LockTime: 0,
|
||||
SubNetworkID: wire.SubNetworkDAGCoin,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
BIN
blockdag/testdata/blk_0_to_4.dat
vendored
BIN
blockdag/testdata/blk_0_to_4.dat
vendored
Binary file not shown.
BIN
blockdag/testdata/blk_3A.dat
vendored
BIN
blockdag/testdata/blk_3A.dat
vendored
Binary file not shown.
BIN
blockdag/testdata/blk_3B.dat
vendored
BIN
blockdag/testdata/blk_3B.dat
vendored
Binary file not shown.
BIN
blockdag/testdata/blk_3C.dat
vendored
BIN
blockdag/testdata/blk_3C.dat
vendored
Binary file not shown.
BIN
blockdag/testdata/blk_3D.dat
vendored
BIN
blockdag/testdata/blk_3D.dat
vendored
Binary file not shown.
@ -625,14 +625,14 @@ var Block100000 = wire.MsgBlock{
|
||||
},
|
||||
},
|
||||
MerkleRoot: daghash.Hash([32]byte{ // Make go vet happy.
|
||||
0xc0, 0x92, 0x53, 0x8f, 0x6f, 0xf7, 0xf5, 0x24,
|
||||
0xd5, 0x33, 0xd4, 0x8b, 0xf3, 0xc0, 0xf8, 0xf9,
|
||||
0x6f, 0xff, 0xfb, 0xb7, 0xdc, 0x39, 0x9d, 0x76,
|
||||
0x8d, 0xb0, 0xe1, 0x9c, 0x2e, 0x6d, 0x22, 0xd9,
|
||||
}), // f3e94742aca4b5ef85488dc37c06c3282295ffec960994b2c0d5ac2a25a95766
|
||||
Timestamp: time.Unix(0x5bbc7588, 0), // 2018-10-09 07:49:35 +0000 UTC
|
||||
Bits: 0x207fffff, // 503382015
|
||||
Nonce: 0xdffffff9,
|
||||
0x0b, 0x79, 0xf5, 0x29, 0x6d, 0x1c, 0xaa, 0x90,
|
||||
0x2f, 0x01, 0xd4, 0x83, 0x9b, 0x2a, 0x04, 0x5e,
|
||||
0xa0, 0x69, 0x2d, 0x16, 0xb5, 0xd7, 0xe4, 0xf3,
|
||||
0xcd, 0xc7, 0xc9, 0xaf, 0xfb, 0xd2, 0x1b, 0x85,
|
||||
}),
|
||||
Timestamp: time.Unix(0x5c22330f, 0),
|
||||
Bits: 0x207fffff,
|
||||
Nonce: 0xdffffffffffffffc,
|
||||
},
|
||||
Transactions: []*wire.MsgTx{
|
||||
{
|
||||
@ -736,7 +736,8 @@ var Block100000 = wire.MsgBlock{
|
||||
},
|
||||
},
|
||||
},
|
||||
LockTime: 0,
|
||||
LockTime: 0,
|
||||
SubNetworkID: wire.SubNetworkDAGCoin,
|
||||
},
|
||||
{
|
||||
Version: 1,
|
||||
@ -804,7 +805,8 @@ var Block100000 = wire.MsgBlock{
|
||||
},
|
||||
},
|
||||
},
|
||||
LockTime: 0,
|
||||
LockTime: 0,
|
||||
SubNetworkID: wire.SubNetworkDAGCoin,
|
||||
},
|
||||
{
|
||||
Version: 1,
|
||||
@ -860,7 +862,8 @@ var Block100000 = wire.MsgBlock{
|
||||
},
|
||||
},
|
||||
},
|
||||
LockTime: 0,
|
||||
LockTime: 0,
|
||||
SubNetworkID: wire.SubNetworkDAGCoin,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -53,25 +53,26 @@ var genesisCoinbaseTx = wire.MsgTx{
|
||||
},
|
||||
},
|
||||
},
|
||||
LockTime: 0,
|
||||
LockTime: 0,
|
||||
SubNetworkID: wire.SubNetworkDAGCoin,
|
||||
}
|
||||
|
||||
// genesisHash is the hash of the first block in the block chain for the main
|
||||
// network (genesis block).
|
||||
var genesisHash = daghash.Hash([daghash.HashSize]byte{ // Make go vet happy.
|
||||
0xc3, 0xc9, 0xa8, 0xba, 0x10, 0x1e, 0x5e, 0xf2,
|
||||
0x03, 0xfd, 0x54, 0x15, 0x34, 0xae, 0x4e, 0x74,
|
||||
0xc5, 0x5f, 0x48, 0x2e, 0xc9, 0xef, 0xba, 0x58,
|
||||
0x92, 0xce, 0x27, 0xfa, 0xf9, 0x00, 0x00, 0x00,
|
||||
0x34, 0x16, 0x17, 0x85, 0x5d, 0xf7, 0x79, 0xde,
|
||||
0xdc, 0x37, 0xf0, 0x57, 0x93, 0x9d, 0x6f, 0x22,
|
||||
0xe5, 0xff, 0xa0, 0x3e, 0xc7, 0x3e, 0x50, 0xf5,
|
||||
0xa1, 0x2a, 0x0a, 0x2e, 0x48, 0x05, 0xc2, 0x47,
|
||||
})
|
||||
|
||||
// genesisMerkleRoot is the hash of the first transaction in the genesis block
|
||||
// for the main network.
|
||||
var genesisMerkleRoot = daghash.Hash([daghash.HashSize]byte{ // Make go vet happy.
|
||||
0x69, 0x1f, 0x2e, 0x9c, 0x49, 0x12, 0x54, 0xc5,
|
||||
0xde, 0x1d, 0x8f, 0xd0, 0x95, 0x40, 0x07, 0xf0,
|
||||
0xda, 0x1b, 0x4c, 0x84, 0x3c, 0x07, 0x94, 0x87,
|
||||
0x6a, 0xd3, 0x0e, 0xca, 0x87, 0xcc, 0x4b, 0xb9,
|
||||
0x79, 0x6e, 0xd7, 0x12, 0x58, 0xea, 0x3f, 0x88,
|
||||
0xa1, 0xfa, 0x7a, 0x67, 0x2b, 0x68, 0x76, 0x6b,
|
||||
0x39, 0x6b, 0x7d, 0x15, 0x6b, 0x1a, 0xb1, 0x96,
|
||||
0xe2, 0x17, 0x2c, 0x4a, 0x6a, 0xad, 0x72, 0x96,
|
||||
})
|
||||
|
||||
// genesisBlock defines the genesis block of the block chain which serves as the
|
||||
@ -80,10 +81,10 @@ var genesisBlock = wire.MsgBlock{
|
||||
Header: wire.BlockHeader{
|
||||
Version: 1,
|
||||
ParentHashes: []daghash.Hash{},
|
||||
MerkleRoot: genesisMerkleRoot, // 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b
|
||||
Timestamp: time.Unix(0x5bbe076c, 0), // 2018-10-10 14:06:36 +0000 UTC
|
||||
Bits: 0x1e00ffff, // 503382015 [000000ffff000000000000000000000000000000000000000000000000000000]
|
||||
Nonce: 0x80000000000d8796, // 9223372036855662486
|
||||
MerkleRoot: genesisMerkleRoot,
|
||||
Timestamp: time.Unix(0x5c238413, 0),
|
||||
Bits: 0x207fffff,
|
||||
Nonce: 0x00000001,
|
||||
},
|
||||
Transactions: []*wire.MsgTx{&genesisCoinbaseTx},
|
||||
}
|
||||
@ -91,10 +92,10 @@ var genesisBlock = wire.MsgBlock{
|
||||
// regTestGenesisHash is the hash of the first block in the block chain for the
|
||||
// regression test network (genesis block).
|
||||
var regTestGenesisHash = daghash.Hash([daghash.HashSize]byte{ // Make go vet happy.
|
||||
0xe7, 0xbe, 0x90, 0x9a, 0x85, 0xf4, 0xea, 0x42,
|
||||
0xe0, 0xd6, 0x68, 0x09, 0xc5, 0xa9, 0xd6, 0x94,
|
||||
0xa2, 0x34, 0x52, 0x4c, 0x5f, 0x1a, 0x77, 0xb1,
|
||||
0xcf, 0x26, 0x12, 0x0a, 0x1b, 0x26, 0x92, 0x13,
|
||||
0x34, 0x16, 0x17, 0x85, 0x5d, 0xf7, 0x79, 0xde,
|
||||
0xdc, 0x37, 0xf0, 0x57, 0x93, 0x9d, 0x6f, 0x22,
|
||||
0xe5, 0xff, 0xa0, 0x3e, 0xc7, 0x3e, 0x50, 0xf5,
|
||||
0xa1, 0x2a, 0x0a, 0x2e, 0x48, 0x05, 0xc2, 0x47,
|
||||
})
|
||||
|
||||
// regTestGenesisMerkleRoot is the hash of the first transaction in the genesis
|
||||
@ -108,10 +109,10 @@ var regTestGenesisBlock = wire.MsgBlock{
|
||||
Header: wire.BlockHeader{
|
||||
Version: 1,
|
||||
ParentHashes: []daghash.Hash{},
|
||||
MerkleRoot: regTestGenesisMerkleRoot, // 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b
|
||||
Timestamp: time.Unix(0x5bbe0d4b, 0), // 2018-06-19 09:00:38 +0000 UTC
|
||||
Bits: 0x207fffff, // 545259519 [7fffff0000000000000000000000000000000000000000000000000000000000]
|
||||
Nonce: 0x00000000,
|
||||
MerkleRoot: genesisMerkleRoot,
|
||||
Timestamp: time.Unix(0x5c238413, 0),
|
||||
Bits: 0x207fffff,
|
||||
Nonce: 0x00000001,
|
||||
},
|
||||
Transactions: []*wire.MsgTx{&genesisCoinbaseTx},
|
||||
}
|
||||
@ -119,10 +120,10 @@ var regTestGenesisBlock = wire.MsgBlock{
|
||||
// testNet3GenesisHash is the hash of the first block in the block chain for the
|
||||
// test network (version 3).
|
||||
var testNet3GenesisHash = daghash.Hash([daghash.HashSize]byte{ // Make go vet happy.
|
||||
0xcb, 0xcb, 0x39, 0xdb, 0xc7, 0x18, 0xe3, 0xd3,
|
||||
0x59, 0xb2, 0xf4, 0xe3, 0x9c, 0x05, 0xa3, 0x1d,
|
||||
0x60, 0xc6, 0xf7, 0x06, 0xb5, 0x93, 0xdf, 0x11,
|
||||
0x71, 0x1b, 0x82, 0xb1, 0xa3, 0x00, 0x00, 0x00,
|
||||
0x34, 0x16, 0x17, 0x85, 0x5d, 0xf7, 0x79, 0xde,
|
||||
0xdc, 0x37, 0xf0, 0x57, 0x93, 0x9d, 0x6f, 0x22,
|
||||
0xe5, 0xff, 0xa0, 0x3e, 0xc7, 0x3e, 0x50, 0xf5,
|
||||
0xa1, 0x2a, 0x0a, 0x2e, 0x48, 0x05, 0xc2, 0x47,
|
||||
})
|
||||
|
||||
// testNet3GenesisMerkleRoot is the hash of the first transaction in the genesis
|
||||
@ -136,10 +137,10 @@ var testNet3GenesisBlock = wire.MsgBlock{
|
||||
Header: wire.BlockHeader{
|
||||
Version: 1,
|
||||
ParentHashes: []daghash.Hash{},
|
||||
MerkleRoot: testNet3GenesisMerkleRoot, // 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b
|
||||
Timestamp: time.Unix(0x5bbe0e49, 0), // 2018-06-19 09:04:06 +0000 UTC
|
||||
Bits: 0x1e00ffff, // 503382015 [000000ffff000000000000000000000000000000000000000000000000000000]
|
||||
Nonce: 0xc00000000032560b, // 2150570811
|
||||
MerkleRoot: genesisMerkleRoot,
|
||||
Timestamp: time.Unix(0x5c238413, 0),
|
||||
Bits: 0x207fffff,
|
||||
Nonce: 0x00000001,
|
||||
},
|
||||
Transactions: []*wire.MsgTx{&genesisCoinbaseTx},
|
||||
}
|
||||
@ -147,10 +148,10 @@ var testNet3GenesisBlock = wire.MsgBlock{
|
||||
// simNetGenesisHash is the hash of the first block in the block chain for the
|
||||
// simulation test network.
|
||||
var simNetGenesisHash = daghash.Hash([daghash.HashSize]byte{ // Make go vet happy.
|
||||
0x4a, 0xc1, 0x82, 0x2e, 0x43, 0x05, 0xea, 0x0c,
|
||||
0x4f, 0xcc, 0x77, 0x87, 0xae, 0x26, 0x48, 0x87,
|
||||
0x50, 0x13, 0xee, 0x2f, 0x55, 0xa7, 0x18, 0xa7,
|
||||
0x1e, 0xf2, 0xd8, 0x7c, 0xc1, 0x13, 0xac, 0x22,
|
||||
0x34, 0x16, 0x17, 0x85, 0x5d, 0xf7, 0x79, 0xde,
|
||||
0xdc, 0x37, 0xf0, 0x57, 0x93, 0x9d, 0x6f, 0x22,
|
||||
0xe5, 0xff, 0xa0, 0x3e, 0xc7, 0x3e, 0x50, 0xf5,
|
||||
0xa1, 0x2a, 0x0a, 0x2e, 0x48, 0x05, 0xc2, 0x47,
|
||||
})
|
||||
|
||||
// simNetGenesisMerkleRoot is the hash of the first transaction in the genesis
|
||||
@ -164,10 +165,10 @@ var simNetGenesisBlock = wire.MsgBlock{
|
||||
Header: wire.BlockHeader{
|
||||
Version: 1,
|
||||
ParentHashes: []daghash.Hash{},
|
||||
MerkleRoot: simNetGenesisMerkleRoot, // 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b
|
||||
Timestamp: time.Unix(0x5bbe00fe, 0), // 2018-10-10 13:39:10 +0000 UTC
|
||||
Bits: 0x207fffff, // 545259519 [7fffff0000000000000000000000000000000000000000000000000000000000]
|
||||
Nonce: 0xdffffffffffffffc, // 1610612733
|
||||
MerkleRoot: genesisMerkleRoot,
|
||||
Timestamp: time.Unix(0x5c238413, 0),
|
||||
Bits: 0x207fffff,
|
||||
Nonce: 0x00000001,
|
||||
},
|
||||
Transactions: []*wire.MsgTx{&genesisCoinbaseTx},
|
||||
}
|
||||
|
@ -121,52 +121,13 @@ func TestSimNetGenesisBlock(t *testing.T) {
|
||||
// genesisBlockBytes are the wire encoded bytes for the genesis block of the
|
||||
// main network as of protocol version 60002.
|
||||
var genesisBlockBytes = []byte{
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x69, 0x1f, 0x2e, /* |.....i..| */
|
||||
0x9c, 0x49, 0x12, 0x54, 0xc5, 0xde, 0x1d, 0x8f, /* |.I.T....| */
|
||||
0xd0, 0x95, 0x40, 0x07, 0xf0, 0xda, 0x1b, 0x4c, /* |..@....L| */
|
||||
0x84, 0x3c, 0x07, 0x94, 0x87, 0x6a, 0xd3, 0x0e, /* |.<...j..| */
|
||||
0xca, 0x87, 0xcc, 0x4b, 0xb9, 0x6c, 0x07, 0xbe, /* |...K.l..| */
|
||||
0x5b, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, /* |[.......| */
|
||||
0x1e, 0x96, 0x87, 0x0d, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
||||
0x80, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, /* |........| */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, /* |........| */
|
||||
0xff, 0xff, 0xff, 0x4d, 0x04, 0xff, 0xff, 0x00, /* |...M....| */
|
||||
0x1d, 0x01, 0x04, 0x45, 0x54, 0x68, 0x65, 0x20, /* |...EThe | */
|
||||
0x54, 0x69, 0x6d, 0x65, 0x73, 0x20, 0x30, 0x33, /* |Times 03| */
|
||||
0x2f, 0x4a, 0x61, 0x6e, 0x2f, 0x32, 0x30, 0x30, /* |/Jan/200| */
|
||||
0x39, 0x20, 0x43, 0x68, 0x61, 0x6e, 0x63, 0x65, /* |9 Chance| */
|
||||
0x6c, 0x6c, 0x6f, 0x72, 0x20, 0x6f, 0x6e, 0x20, /* |llor on | */
|
||||
0x62, 0x72, 0x69, 0x6e, 0x6b, 0x20, 0x6f, 0x66, /* |brink of| */
|
||||
0x20, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x20, /* | second | */
|
||||
0x62, 0x61, 0x69, 0x6c, 0x6f, 0x75, 0x74, 0x20, /* |bailout | */
|
||||
0x66, 0x6f, 0x72, 0x20, 0x62, 0x61, 0x6e, 0x6b, /* |for bank| */
|
||||
0x73, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* |s.......| */
|
||||
0xff, 0x01, 0x00, 0xf2, 0x05, 0x2a, 0x01, 0x00, /* |.....*..| */
|
||||
0x00, 0x00, 0x43, 0x41, 0x04, 0x67, 0x8a, 0xfd, /* |..CA.g..| */
|
||||
0xb0, 0xfe, 0x55, 0x48, 0x27, 0x19, 0x67, 0xf1, /* |..UH'.g.| */
|
||||
0xa6, 0x71, 0x30, 0xb7, 0x10, 0x5c, 0xd6, 0xa8, /* |.q0..\..| */
|
||||
0x28, 0xe0, 0x39, 0x09, 0xa6, 0x79, 0x62, 0xe0, /* |(.9..yb.| */
|
||||
0xea, 0x1f, 0x61, 0xde, 0xb6, 0x49, 0xf6, 0xbc, /* |..a..I..| */
|
||||
0x3f, 0x4c, 0xef, 0x38, 0xc4, 0xf3, 0x55, 0x04, /* |?L.8..U.| */
|
||||
0xe5, 0x1e, 0xc1, 0x12, 0xde, 0x5c, 0x38, 0x4d, /* |.....\8M| */
|
||||
0xf7, 0xba, 0x0b, 0x8d, 0x57, 0x8a, 0x4c, 0x70, /* |....W.Lp| */
|
||||
0x2b, 0x6b, 0xf1, 0x1d, 0x5f, 0xac, 0x00, 0x00, /* |+k.._...| */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |......| */
|
||||
}
|
||||
|
||||
// regTestGenesisBlockBytes are the wire encoded bytes for the genesis block of
|
||||
// the regression test network as of protocol version 60002.
|
||||
var regTestGenesisBlockBytes = []byte{
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x69, 0x1f, 0x2e, /* |.....i..| */
|
||||
0x9c, 0x49, 0x12, 0x54, 0xc5, 0xde, 0x1d, 0x8f, /* |.I.T....| */
|
||||
0xd0, 0x95, 0x40, 0x07, 0xf0, 0xda, 0x1b, 0x4c, /* |..@....L| */
|
||||
0x84, 0x3c, 0x07, 0x94, 0x87, 0x6a, 0xd3, 0x0e, /* |.<...j..| */
|
||||
0xca, 0x87, 0xcc, 0x4b, 0xb9, 0x4b, 0x0d, 0xbe, /* |...K.K..| */
|
||||
0x5b, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7f, /* |[.......| */
|
||||
0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* | .......| */
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x79, 0x6e, 0xd7, /* |.....yn.| */
|
||||
0x12, 0x58, 0xea, 0x3f, 0x88, 0xa1, 0xfa, 0x7a, /* |.X.?...z| */
|
||||
0x67, 0x2b, 0x68, 0x76, 0x6b, 0x39, 0x6b, 0x7d, /* |g+hvk9k}| */
|
||||
0x15, 0x6b, 0x1a, 0xb1, 0x96, 0xe2, 0x17, 0x2c, /* |.k.....,| */
|
||||
0x4a, 0x6a, 0xad, 0x72, 0x96, 0x13, 0x84, 0x23, /* |Jj.r...#| */
|
||||
0x5c, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7f, /* |\.......| */
|
||||
0x20, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* | .......| */
|
||||
0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, /* |........| */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
||||
@ -193,20 +154,61 @@ var regTestGenesisBlockBytes = []byte{
|
||||
0xe5, 0x1e, 0xc1, 0x12, 0xde, 0x5c, 0x38, 0x4d, /* |.....\8M| */
|
||||
0xf7, 0xba, 0x0b, 0x8d, 0x57, 0x8a, 0x4c, 0x70, /* |....W.Lp| */
|
||||
0x2b, 0x6b, 0xf1, 0x1d, 0x5f, 0xac, 0x00, 0x00, /* |+k.._...| */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, /* |........| */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |......| */
|
||||
}
|
||||
|
||||
// regTestGenesisBlockBytes are the wire encoded bytes for the genesis block of
|
||||
// the regression test network as of protocol version 60002.
|
||||
var regTestGenesisBlockBytes = []byte{
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x79, 0x6e, 0xd7, /* |.....yn.| */
|
||||
0x12, 0x58, 0xea, 0x3f, 0x88, 0xa1, 0xfa, 0x7a, /* |.X.?...z| */
|
||||
0x67, 0x2b, 0x68, 0x76, 0x6b, 0x39, 0x6b, 0x7d, /* |g+hvk9k}| */
|
||||
0x15, 0x6b, 0x1a, 0xb1, 0x96, 0xe2, 0x17, 0x2c, /* |.k.....,| */
|
||||
0x4a, 0x6a, 0xad, 0x72, 0x96, 0x13, 0x84, 0x23, /* |Jj.r...#| */
|
||||
0x5c, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7f, /* |\.......| */
|
||||
0x20, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* | .......| */
|
||||
0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, /* |........| */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, /* |........| */
|
||||
0xff, 0xff, 0xff, 0x4d, 0x04, 0xff, 0xff, 0x00, /* |...M....| */
|
||||
0x1d, 0x01, 0x04, 0x45, 0x54, 0x68, 0x65, 0x20, /* |...EThe | */
|
||||
0x54, 0x69, 0x6d, 0x65, 0x73, 0x20, 0x30, 0x33, /* |Times 03| */
|
||||
0x2f, 0x4a, 0x61, 0x6e, 0x2f, 0x32, 0x30, 0x30, /* |/Jan/200| */
|
||||
0x39, 0x20, 0x43, 0x68, 0x61, 0x6e, 0x63, 0x65, /* |9 Chance| */
|
||||
0x6c, 0x6c, 0x6f, 0x72, 0x20, 0x6f, 0x6e, 0x20, /* |llor on | */
|
||||
0x62, 0x72, 0x69, 0x6e, 0x6b, 0x20, 0x6f, 0x66, /* |brink of| */
|
||||
0x20, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x20, /* | second | */
|
||||
0x62, 0x61, 0x69, 0x6c, 0x6f, 0x75, 0x74, 0x20, /* |bailout | */
|
||||
0x66, 0x6f, 0x72, 0x20, 0x62, 0x61, 0x6e, 0x6b, /* |for bank| */
|
||||
0x73, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* |s.......| */
|
||||
0xff, 0x01, 0x00, 0xf2, 0x05, 0x2a, 0x01, 0x00, /* |.....*..| */
|
||||
0x00, 0x00, 0x43, 0x41, 0x04, 0x67, 0x8a, 0xfd, /* |..CA.g..| */
|
||||
0xb0, 0xfe, 0x55, 0x48, 0x27, 0x19, 0x67, 0xf1, /* |..UH'.g.| */
|
||||
0xa6, 0x71, 0x30, 0xb7, 0x10, 0x5c, 0xd6, 0xa8, /* |.q0..\..| */
|
||||
0x28, 0xe0, 0x39, 0x09, 0xa6, 0x79, 0x62, 0xe0, /* |(.9..yb.| */
|
||||
0xea, 0x1f, 0x61, 0xde, 0xb6, 0x49, 0xf6, 0xbc, /* |..a..I..| */
|
||||
0x3f, 0x4c, 0xef, 0x38, 0xc4, 0xf3, 0x55, 0x04, /* |?L.8..U.| */
|
||||
0xe5, 0x1e, 0xc1, 0x12, 0xde, 0x5c, 0x38, 0x4d, /* |.....\8M| */
|
||||
0xf7, 0xba, 0x0b, 0x8d, 0x57, 0x8a, 0x4c, 0x70, /* |....W.Lp| */
|
||||
0x2b, 0x6b, 0xf1, 0x1d, 0x5f, 0xac, 0x00, 0x00, /* |+k.._...| */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, /* |........| */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |......| */
|
||||
}
|
||||
|
||||
// testNet3GenesisBlockBytes are the wire encoded bytes for the genesis block of
|
||||
// the test network (version 3) as of protocol version 60002.
|
||||
var testNet3GenesisBlockBytes = []byte{
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x69, 0x1f, 0x2e, /* |.....i..| */
|
||||
0x9c, 0x49, 0x12, 0x54, 0xc5, 0xde, 0x1d, 0x8f, /* |.I.T....| */
|
||||
0xd0, 0x95, 0x40, 0x07, 0xf0, 0xda, 0x1b, 0x4c, /* |..@....L| */
|
||||
0x84, 0x3c, 0x07, 0x94, 0x87, 0x6a, 0xd3, 0x0e, /* |.<...j..| */
|
||||
0xca, 0x87, 0xcc, 0x4b, 0xb9, 0x49, 0x0e, 0xbe, /* |...K.I..| */
|
||||
0x5b, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, /* |[.......| */
|
||||
0x1e, 0x0b, 0x56, 0x32, 0x00, 0x00, 0x00, 0x00, /* |..V2....| */
|
||||
0xc0, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, /* |........| */
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x79, 0x6e, 0xd7, /* |.....yn.| */
|
||||
0x12, 0x58, 0xea, 0x3f, 0x88, 0xa1, 0xfa, 0x7a, /* |.X.?...z| */
|
||||
0x67, 0x2b, 0x68, 0x76, 0x6b, 0x39, 0x6b, 0x7d, /* |g+hvk9k}| */
|
||||
0x15, 0x6b, 0x1a, 0xb1, 0x96, 0xe2, 0x17, 0x2c, /* |.k.....,| */
|
||||
0x4a, 0x6a, 0xad, 0x72, 0x96, 0x13, 0x84, 0x23, /* |Jj.r...#| */
|
||||
0x5c, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7f, /* |\.......| */
|
||||
0x20, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* | .......| */
|
||||
0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, /* |........| */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
||||
@ -232,20 +234,21 @@ var testNet3GenesisBlockBytes = []byte{
|
||||
0xe5, 0x1e, 0xc1, 0x12, 0xde, 0x5c, 0x38, 0x4d, /* |.....\8M| */
|
||||
0xf7, 0xba, 0x0b, 0x8d, 0x57, 0x8a, 0x4c, 0x70, /* |....W.Lp| */
|
||||
0x2b, 0x6b, 0xf1, 0x1d, 0x5f, 0xac, 0x00, 0x00, /* |+k.._...| */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, /* |........| */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |......| */
|
||||
}
|
||||
|
||||
// simNetGenesisBlockBytes are the wire encoded bytes for the genesis block of
|
||||
// the simulation test network as of protocol version 70002.
|
||||
var simNetGenesisBlockBytes = []byte{
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x69, 0x1f, 0x2e, /* |.....i..| */
|
||||
0x9c, 0x49, 0x12, 0x54, 0xc5, 0xde, 0x1d, 0x8f, /* |.I.T....| */
|
||||
0xd0, 0x95, 0x40, 0x07, 0xf0, 0xda, 0x1b, 0x4c, /* |..@....L| */
|
||||
0x84, 0x3c, 0x07, 0x94, 0x87, 0x6a, 0xd3, 0x0e, /* |.<...j..| */
|
||||
0xca, 0x87, 0xcc, 0x4b, 0xb9, 0xfe, 0x00, 0xbe, /* |...K....| */
|
||||
0x5b, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7f, /* |[.......| */
|
||||
0x20, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, /* | .......| */
|
||||
0xdf, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, /* |........| */
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x79, 0x6e, 0xd7, /* |.....yn.| */
|
||||
0x12, 0x58, 0xea, 0x3f, 0x88, 0xa1, 0xfa, 0x7a, /* |.X.?...z| */
|
||||
0x67, 0x2b, 0x68, 0x76, 0x6b, 0x39, 0x6b, 0x7d, /* |g+hvk9k}| */
|
||||
0x15, 0x6b, 0x1a, 0xb1, 0x96, 0xe2, 0x17, 0x2c, /* |.k.....,| */
|
||||
0x4a, 0x6a, 0xad, 0x72, 0x96, 0x13, 0x84, 0x23, /* |Jj.r...#| */
|
||||
0x5c, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7f, /* |\.......| */
|
||||
0x20, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* | .......| */
|
||||
0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, /* |........| */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |........| */
|
||||
@ -271,5 +274,6 @@ var simNetGenesisBlockBytes = []byte{
|
||||
0xe5, 0x1e, 0xc1, 0x12, 0xde, 0x5c, 0x38, 0x4d, /* |.....\8M| */
|
||||
0xf7, 0xba, 0x0b, 0x8d, 0x57, 0x8a, 0x4c, 0x70, /* |....W.Lp| */
|
||||
0x2b, 0x6b, 0xf1, 0x1d, 0x5f, 0xac, 0x00, 0x00, /* |+k.._...| */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, /* |........| */
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* |......| */
|
||||
}
|
||||
|
@ -173,5 +173,5 @@ func Example_blockStorageAndRetrieval() {
|
||||
fmt.Printf("Serialized block size: %d bytes\n", len(loadedBlockBytes))
|
||||
|
||||
// Output:
|
||||
// Serialized block size: 270 bytes
|
||||
// Serialized block size: 278 bytes
|
||||
}
|
||||
|
BIN
database/testdata/blocks1-256.bz2
vendored
BIN
database/testdata/blocks1-256.bz2
vendored
Binary file not shown.
5
database/testdata/generator.go
vendored
5
database/testdata/generator.go
vendored
@ -48,7 +48,7 @@ func generateBlock(parent *wire.MsgBlock) *wire.MsgBlock {
|
||||
ParentHashes: []daghash.Hash{parent.BlockHash()},
|
||||
MerkleRoot: genesisMerkleRoot,
|
||||
Timestamp: time.Unix(0x5b28c4c8, 0), // 2018-06-19 08:54:32 +0000 UTC
|
||||
Bits: 0x1e00ffff, // 503382015 [000000ffff000000000000000000000000000000000000000000000000000000]
|
||||
Bits: 0x2e00ffff, // 503382015 [000000ffff000000000000000000000000000000000000000000000000000000]
|
||||
Nonce: 0xc0192550, // 2148484547
|
||||
},
|
||||
Transactions: []*wire.MsgTx{&genesisCoinbaseTx},
|
||||
@ -142,7 +142,8 @@ var genesisCoinbaseTx = wire.MsgTx{
|
||||
},
|
||||
},
|
||||
},
|
||||
LockTime: 0,
|
||||
LockTime: 0,
|
||||
SubNetworkID: wire.SubNetworkDAGCoin,
|
||||
}
|
||||
|
||||
var genesisMerkleRoot = daghash.Hash([daghash.HashSize]byte{ // Make go vet happy.
|
||||
|
@ -140,7 +140,7 @@ func TestCalcPriority(t *testing.T) {
|
||||
utxoSet: newUTXOSet([]*wire.MsgTx{commonSourceTx1},
|
||||
[]int32{7}),
|
||||
nextHeight: 169,
|
||||
want: 1.5576923076923077e+10,
|
||||
want: 1.35e+10,
|
||||
},
|
||||
{
|
||||
name: "one height 100 input, prio tx height 169",
|
||||
@ -148,7 +148,7 @@ func TestCalcPriority(t *testing.T) {
|
||||
utxoSet: newUTXOSet([]*wire.MsgTx{commonSourceTx1},
|
||||
[]int32{100}),
|
||||
nextHeight: 169,
|
||||
want: 6.634615384615385e+09,
|
||||
want: 5.75e+09,
|
||||
},
|
||||
{
|
||||
name: "one height 7 input, prio tx height 100000",
|
||||
@ -156,7 +156,7 @@ func TestCalcPriority(t *testing.T) {
|
||||
utxoSet: newUTXOSet([]*wire.MsgTx{commonSourceTx1},
|
||||
[]int32{7}),
|
||||
nextHeight: 100000,
|
||||
want: 9.61471153846154e+12,
|
||||
want: 8.33275e+12,
|
||||
},
|
||||
{
|
||||
name: "one height 100 input, prio tx height 100000",
|
||||
@ -164,7 +164,7 @@ func TestCalcPriority(t *testing.T) {
|
||||
utxoSet: newUTXOSet([]*wire.MsgTx{commonSourceTx1},
|
||||
[]int32{100}),
|
||||
nextHeight: 100000,
|
||||
want: 9.60576923076923e+12,
|
||||
want: 8.325e+12,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -54,10 +54,10 @@ func TestBlock(t *testing.T) {
|
||||
|
||||
// Hashes for the transactions in Block100000.
|
||||
wantTxHashes := []string{
|
||||
"8913f1fa776ba67b1bffc156788caa41d914f9d2c90a864421259e5977749669",
|
||||
"0b999b0aed782261104e6417879f2e9b74306f80a92a6bff489d513b68c7be8b",
|
||||
"62bbb36f70ee6d216bf5709eaa7297b1e3b1c3ca81f61e3dcc1079b9a5386e61",
|
||||
"4c6c95b556627e3ecfdd31f3bed5fd6fffc6d4e887b268d0b0bc82c977305b6c",
|
||||
"4f2a5f1e00034ed3222e0e7fae8485ad3154d40b21b1c1b64ec74ce389a1bb1d",
|
||||
"cdd164e1b3c910e1b54349d442d26541830d0551a15c8b2e202aa7f96ccf3b32",
|
||||
"7fb0543009c39a12a0e5b3c23f157c9152f9e956412a825d296d1e3826dcf81c",
|
||||
"ba611a9e39e784e51ea9efe66453de7a0355deae454f63c526a1938a58f683fc",
|
||||
}
|
||||
|
||||
// Create a new block to nuke all cached data.
|
||||
@ -146,10 +146,10 @@ func TestBlock(t *testing.T) {
|
||||
|
||||
// Transaction offsets and length for the transaction in Block100000.
|
||||
wantTxLocs := []wire.TxLoc{
|
||||
{TxStart: 122, TxLen: 143},
|
||||
{TxStart: 265, TxLen: 267},
|
||||
{TxStart: 532, TxLen: 265},
|
||||
{TxStart: 797, TxLen: 233},
|
||||
{TxStart: 122, TxLen: 151},
|
||||
{TxStart: 273, TxLen: 275},
|
||||
{TxStart: 548, TxLen: 273},
|
||||
{TxStart: 821, TxLen: 241},
|
||||
}
|
||||
|
||||
// Ensure the transaction location information is accurate.
|
||||
@ -361,7 +361,8 @@ var Block100000 = wire.MsgBlock{
|
||||
},
|
||||
},
|
||||
},
|
||||
LockTime: 0,
|
||||
LockTime: 0,
|
||||
SubNetworkID: wire.SubNetworkDAGCoin,
|
||||
},
|
||||
{
|
||||
Version: 1,
|
||||
@ -430,7 +431,8 @@ var Block100000 = wire.MsgBlock{
|
||||
},
|
||||
},
|
||||
},
|
||||
LockTime: 0,
|
||||
LockTime: 0,
|
||||
SubNetworkID: wire.SubNetworkDAGCoin,
|
||||
},
|
||||
{
|
||||
Version: 1,
|
||||
@ -498,7 +500,8 @@ var Block100000 = wire.MsgBlock{
|
||||
},
|
||||
},
|
||||
},
|
||||
LockTime: 0,
|
||||
LockTime: 0,
|
||||
SubNetworkID: wire.SubNetworkDAGCoin,
|
||||
},
|
||||
{
|
||||
Version: 1,
|
||||
@ -554,7 +557,8 @@ var Block100000 = wire.MsgBlock{
|
||||
},
|
||||
},
|
||||
},
|
||||
LockTime: 0,
|
||||
LockTime: 0,
|
||||
SubNetworkID: wire.SubNetworkDAGCoin,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -255,7 +255,7 @@ func TestFilterBloomMatch(t *testing.T) {
|
||||
"3D11000000001976A91404943FDD508053C75000106D3BC6" +
|
||||
"E2754DBCFF1988AC2F15DE00000000001976A914A266436D" +
|
||||
"2965547608B9E15D9032A7B9D64FA43188AC000000000000" +
|
||||
"0000"
|
||||
"00000100000000000000"
|
||||
strBytes, err := hex.DecodeString(str)
|
||||
if err != nil {
|
||||
t.Errorf("TestFilterBloomMatch DecodeString failure: %v", err)
|
||||
@ -266,8 +266,8 @@ func TestFilterBloomMatch(t *testing.T) {
|
||||
t.Errorf("TestFilterBloomMatch NewTxFromBytes failure: %v", err)
|
||||
return
|
||||
}
|
||||
spendingTxStr := "0100000001549F371382F2653D7F894BC8DC84F4BD219855" +
|
||||
"E7E31270B6DEE3D2B60A46421C000000008C493046022100" +
|
||||
spendingTxStr := "0100000001F66914B25A46137FB0551E95CCE775254B8711" +
|
||||
"D01D7D258C119396E57E105622000000008C493046022100" +
|
||||
"DA0DC6AECEFE1E06EFDF05773757DEB168820930E3B0D03F" +
|
||||
"46F5FCF150BF990C022100D25B5C87040076E4F253F8262E" +
|
||||
"763E2DD51E7FF0BE157727C4BC42807F17BD39014104E6C2" +
|
||||
@ -277,7 +277,7 @@ func TestFilterBloomMatch(t *testing.T) {
|
||||
"A7940E000000001976A914BADEECFDEF0507247FC8F74241" +
|
||||
"D73BC039972D7B88AC4094A802000000001976A914C10932" +
|
||||
"483FEC93ED51F5FE95E72559F2CC7043F988AC0000000000" +
|
||||
"00000000"
|
||||
"0000000100000000000000"
|
||||
spendingTxBytes, err := hex.DecodeString(spendingTxStr)
|
||||
if err != nil {
|
||||
t.Errorf("TestFilterBloomMatch DecodeString failed to decode spendingTxStr: %v", err)
|
||||
@ -291,7 +291,7 @@ func TestFilterBloomMatch(t *testing.T) {
|
||||
}
|
||||
|
||||
f := bloom.NewFilter(10, 0, 0.000001, wire.BloomUpdateAll)
|
||||
inputStr := "1c42460ab6d2e3deb67012e3e7559821bdf484dcc84b897f3d65f28213379f54" // byte-reversed tx hash
|
||||
inputStr := "2256107ee59693118c257d1dd011874b2575e7cc951e55b07f13465ab21469f6" // byte-reversed tx hash
|
||||
hash, err := daghash.NewHashFromStr(inputStr)
|
||||
if err != nil {
|
||||
t.Errorf("TestFilterBloomMatch NewHashFromStr failed: %v\n", err)
|
||||
@ -303,7 +303,7 @@ func TestFilterBloomMatch(t *testing.T) {
|
||||
}
|
||||
|
||||
f = bloom.NewFilter(10, 0, 0.000001, wire.BloomUpdateAll)
|
||||
inputStr = "549f371382f2653d7f894bc8dc84f4bd219855e7e31270b6dee3d2b60a46421c"
|
||||
inputStr = "f66914b25a46137fb0551e95cce775254b8711d01d7d258c119396e57e105622" // non-reversed tx hash
|
||||
hashBytes, err := hex.DecodeString(inputStr)
|
||||
if err != nil {
|
||||
t.Errorf("TestFilterBloomMatch DecodeString failed: %v\n", err)
|
||||
@ -510,7 +510,8 @@ func TestFilterInsertP2PubKeyOnly(t *testing.T) {
|
||||
0x1E, 0xC0, 0xF0, 0xDD, 0x5B, 0x2E, 0x86, 0xE7, 0x16, 0x8C, 0xEF,
|
||||
0xE0, 0xD8, 0x11, 0x13, 0xC3, 0x80, 0x74, 0x20, 0xCE, 0x13, 0xAD,
|
||||
0x13, 0x57, 0x23, 0x1A, 0x22, 0x52, 0x24, 0x7D, 0x97, 0xA4, 0x6A,
|
||||
0x91, 0xAC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x91, 0xAC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
|
||||
0x01, 0x00, 0x00, 0x00, 0x01, 0xBC, 0xAD, 0x20, 0xA6, 0xA2, 0x98, // Txs[1]
|
||||
0x27, 0xD1, 0x42, 0x4F, 0x08, 0x98, 0x92, 0x55, 0x12, 0x0B, 0xF7,
|
||||
@ -530,7 +531,7 @@ func TestFilterInsertP2PubKeyOnly(t *testing.T) {
|
||||
0x00, 0x19, 0x76, 0xA9, 0x14, 0x1B, 0x8D, 0xD1, 0x3B, 0x99, 0x4B,
|
||||
0xCF, 0xC7, 0x87, 0xB3, 0x2A, 0xEA, 0xDF, 0x58, 0xCC, 0xB3, 0x61,
|
||||
0x5C, 0xBD, 0x54, 0x88, 0xAC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00,
|
||||
0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x03, 0xFD, 0xAC, 0xF9, 0xB3, 0xEB, 0x07, // Txs[2]
|
||||
0x74, 0x12, 0xE7, 0xA9, 0x68, 0xD2, 0xE4, 0xF1, 0x1B, 0x9A, 0x9D,
|
||||
0xEE, 0x31, 0x2D, 0x66, 0x61, 0x87, 0xED, 0x77, 0xEE, 0x7D, 0x26,
|
||||
@ -573,7 +574,8 @@ func TestFilterInsertP2PubKeyOnly(t *testing.T) {
|
||||
0x44, 0x60, 0x03, 0x00, 0x00, 0x00, 0x19, 0x76, 0xA9, 0x14, 0xC7,
|
||||
0xB5, 0x51, 0x41, 0xD0, 0x97, 0xEA, 0x5D, 0xF7, 0xA0, 0xED, 0x33,
|
||||
0x0C, 0xF7, 0x94, 0x37, 0x6E, 0x53, 0xEC, 0x8D, 0x88, 0xAC, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x04, 0x5B, 0xF0, 0xE2, 0x14, 0xAA, 0x40, // Txs[3]
|
||||
0x69, 0xA3, 0xE7, 0x92, 0xEC, 0xEE, 0x1E, 0x1B, 0xF0, 0xC1, 0xD3,
|
||||
0x97, 0xCD, 0xE8, 0xDD, 0x08, 0x13, 0x8F, 0x4B, 0x72, 0xA0, 0x06,
|
||||
@ -645,7 +647,8 @@ func TestFilterInsertP2PubKeyOnly(t *testing.T) {
|
||||
0x17, 0xA8, 0x04, 0x00, 0x00, 0x00, 0x19, 0x76, 0xA9, 0x14, 0xB6,
|
||||
0xEF, 0xD8, 0x0D, 0x99, 0x17, 0x9F, 0x4F, 0x4F, 0xF6, 0xF4, 0xDD,
|
||||
0x0A, 0x00, 0x7D, 0x01, 0x8C, 0x38, 0x5D, 0x21,
|
||||
0x88, 0xAC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x88, 0xAC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x01, 0x83, 0x45, 0x37, 0xB2, 0xF1, 0xCE, // Txs[4]
|
||||
0x8E, 0xF9, 0x37, 0x3A, 0x25, 0x8E, 0x10, 0x54, 0x5C, 0xE5, 0xA5,
|
||||
0x0B, 0x75, 0x8D, 0xF6, 0x16, 0xCD, 0x43, 0x56, 0xE0, 0x03, 0x25,
|
||||
@ -670,7 +673,7 @@ func TestFilterInsertP2PubKeyOnly(t *testing.T) {
|
||||
0x00, 0x19, 0x76, 0xA9, 0x14, 0xA8, 0x4E, 0x27, 0x29, 0x33, 0xAA,
|
||||
0xF8, 0x7E, 0x17, 0x15, 0xD7, 0x78, 0x6C, 0x51, 0xDF, 0xAE, 0xB5,
|
||||
0xB6, 0x5A, 0x6F, 0x88, 0xAC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00,
|
||||
0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x01, 0x43, 0xAC, 0x81, 0xC8, 0xE6, 0xF6, // Txs[5]
|
||||
0xEF, 0x30, 0x7D, 0xFE, 0x17, 0xF3, 0xD9, 0x06, 0xD9, 0x99, 0xE2,
|
||||
0x3E, 0x01, 0x89, 0xFD, 0xA8, 0x38, 0xC5, 0x51, 0x0D, 0x85, 0x09,
|
||||
@ -695,7 +698,7 @@ func TestFilterInsertP2PubKeyOnly(t *testing.T) {
|
||||
0x00, 0x00, 0x19, 0x76, 0xA9, 0x14, 0x64, 0x8D, 0x04, 0x34, 0x1D,
|
||||
0x00, 0xD7, 0x96, 0x8B, 0x34, 0x05, 0xC0, 0x34, 0xAD, 0xC3, 0x8D,
|
||||
0x4D, 0x8F, 0xB9, 0xBD, 0x88, 0xAC, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x02, 0x48, 0xCC, 0x91, 0x75, 0x01, 0xEA, // Txs[6]
|
||||
0x5C, 0x55, 0xF4, 0xA8, 0xD2, 0x00, 0x9C, 0x05, 0x67, 0xC4, 0x0C,
|
||||
0xFE, 0x03, 0x7C, 0x2E, 0x71, 0xAF, 0x01, 0x7D, 0x0A, 0x45, 0x2F,
|
||||
@ -734,7 +737,8 @@ func TestFilterInsertP2PubKeyOnly(t *testing.T) {
|
||||
0x00, 0x00, 0x00, 0x00, 0x19, 0x76, 0xA9, 0x14, 0x8E, 0xDB, 0x68,
|
||||
0x82, 0x2F, 0x1A, 0xD5, 0x80, 0xB0, 0x43, 0xC7, 0xB3, 0xDF, 0x2E,
|
||||
0x40, 0x0F, 0x86, 0x99, 0xEB, 0x48, 0x88, 0xAC, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00,
|
||||
}
|
||||
block, err := util.NewBlockFromBytes(blockBytes)
|
||||
if err != nil {
|
||||
@ -768,7 +772,7 @@ func TestFilterInsertP2PubKeyOnly(t *testing.T) {
|
||||
_, _ = bloom.NewMerkleBlock(block, f)
|
||||
|
||||
// We should match the generation pubkey
|
||||
inputStr = "d0eee4e3257d0d9cc6dcef5180b53a659ce7ba007eb8150124daecfab610c9b8" //1st tx hash
|
||||
inputStr = "807014abe7988704c8097b6ea882489cb1dc54daff96947eab9f6c04f2271252" //1st tx hash
|
||||
hash, err := daghash.NewHashFromStr(inputStr)
|
||||
if err != nil {
|
||||
t.Errorf("TestMerkleBlockP2PubKeyOnly NewHashFromStr failed: %v", err)
|
||||
|
@ -41,7 +41,9 @@ func TestMerkleBlock3(t *testing.T) {
|
||||
0x5F, 0x64, 0x86, 0x81, 0x37, 0xA1, 0x8C, 0xDD, 0x85, 0xCB, 0xBB,
|
||||
0x4C, 0x74, 0xFB, 0xCC, 0xFD, 0x4F, 0x49, 0x63, 0x9C, 0xF1, 0xBD,
|
||||
0xC9, 0x4A, 0x56, 0x72, 0xBB, 0x15, 0xAD, 0x5D, 0x4C, 0xAC, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00,
|
||||
}
|
||||
|
||||
blk, err := util.NewBlockFromBytes(blockBytes)
|
||||
if err != nil {
|
||||
@ -51,7 +53,7 @@ func TestMerkleBlock3(t *testing.T) {
|
||||
|
||||
f := bloom.NewFilter(10, 0, 0.000001, wire.BloomUpdateAll)
|
||||
|
||||
inputStr := "63194f18be0af63f2c6bc9dc0f777cbefed3d9415c4af83f3ee3a3d669c00cb5"
|
||||
inputStr := "4ee77df1e2c3126a4a3469e7b1ee3c73093f7f79fef726690fde230c47a02dc6"
|
||||
hash, err := daghash.NewHashFromStr(inputStr)
|
||||
if err != nil {
|
||||
t.Errorf("TestMerkleBlock3 NewHashFromStr failed: %v", err)
|
||||
@ -63,14 +65,22 @@ func TestMerkleBlock3(t *testing.T) {
|
||||
mBlock, _ := bloom.NewMerkleBlock(blk, f)
|
||||
|
||||
want := []byte{
|
||||
0x01, 0x00, 0x00, 0x00, 0x01, 0x79, 0xcd, 0xa8, 0x56, 0xb1, 0x43, 0xd9, 0xdb, 0x2c, 0x1c, 0xaf,
|
||||
0xf0, 0x1d, 0x1a, 0xec, 0xc8, 0x63, 0x0d, 0x30, 0x62, 0x5d, 0x10, 0xe8, 0xb4, 0xb8, 0xb0, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xb5, 0x0c, 0xc0, 0x69, 0xd6, 0xa3, 0xe3, 0x3e, 0x3f, 0xf8, 0x4a,
|
||||
0x5c, 0x41, 0xd9, 0xd3, 0xfe, 0xbe, 0x7c, 0x77, 0x0f, 0xdc, 0xc9, 0x6b, 0x2c, 0x3f, 0xf6, 0x0a,
|
||||
0xbe, 0x18, 0x4f, 0x19, 0x63, 0x67, 0x29, 0x1b, 0x4d, 0x00, 0x00, 0x00, 0x00, 0x4c, 0x86, 0x04,
|
||||
0x1b, 0x8f, 0xa4, 0x5d, 0x63, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x70, 0x2b,
|
||||
0x1e, 0x73, 0x5a, 0x15, 0xbc, 0xd7, 0xdb, 0xc9, 0x6f, 0xe5, 0x0f, 0x86, 0xe9, 0xd1, 0x9b, 0xdf,
|
||||
0x75, 0x95, 0x30, 0xa6, 0x95, 0x06, 0x6e, 0xe5, 0x1e, 0xb0, 0xb9, 0x94, 0xe8, 0x01, 0x01, 0x00,
|
||||
0x01, 0x00, 0x00, 0x00, 0x01, 0x79, 0xcd, 0xa8,
|
||||
0x56, 0xb1, 0x43, 0xd9, 0xdb, 0x2c, 0x1c, 0xaf,
|
||||
0xf0, 0x1d, 0x1a, 0xec, 0xc8, 0x63, 0x0d, 0x30,
|
||||
0x62, 0x5d, 0x10, 0xe8, 0xb4, 0xb8, 0xb0, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0xb5, 0x0c, 0xc0,
|
||||
0x69, 0xd6, 0xa3, 0xe3, 0x3e, 0x3f, 0xf8, 0x4a,
|
||||
0x5c, 0x41, 0xd9, 0xd3, 0xfe, 0xbe, 0x7c, 0x77,
|
||||
0x0f, 0xdc, 0xc9, 0x6b, 0x2c, 0x3f, 0xf6, 0x0a,
|
||||
0xbe, 0x18, 0x4f, 0x19, 0x63, 0x67, 0x29, 0x1b,
|
||||
0x4d, 0x00, 0x00, 0x00, 0x00, 0x4c, 0x86, 0x04,
|
||||
0x1b, 0x8f, 0xa4, 0x5d, 0x63, 0x00, 0x00, 0x00,
|
||||
0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0xaa, 0xda,
|
||||
0x38, 0x18, 0x2c, 0x17, 0xd8, 0x41, 0x3b, 0xd2,
|
||||
0xba, 0xd3, 0x16, 0x26, 0xb0, 0x96, 0x84, 0x6f,
|
||||
0x6b, 0xd4, 0xc4, 0xd3, 0xa6, 0x64, 0x45, 0x78,
|
||||
0x62, 0x5a, 0x23, 0xd4, 0x69, 0x92, 0x01, 0x00,
|
||||
}
|
||||
t.Log(spew.Sdump(want))
|
||||
if err != nil {
|
||||
|
@ -223,19 +223,19 @@ func TestMinPrioritySelector(t *testing.T) {
|
||||
var (
|
||||
// should be two outpoints, with 1st one having 0.035BTC value.
|
||||
testSimpleCoinNumConfs = int64(1)
|
||||
testSimpleCoinTxHash = "a0a82fc00cdfde26119c0795c06eea7c9db5f3c9d26dd1f883ade0ba70b29970"
|
||||
testSimpleCoinTxHex = "0100000001a214a110f79e4abe073865ea5b3745c6e82c91" +
|
||||
"3bad44be70652804a5e4003b0a010000008c493046022100" +
|
||||
"edd18a69664efa57264be207100c203e6cade1888cbb88a0" +
|
||||
"ad748548256bb2f0022100f1027dc2e6c7f248d78af1dd90" +
|
||||
"027b5b7d8ec563bb62aa85d4e74d6376f3868c0141048f37" +
|
||||
"57b65ed301abd1b0e8942d1ab5b50594d3314cff0299f300" +
|
||||
"c696376a0a9bf72e74710a8af7a5372d4af4bb519e2701a0" +
|
||||
"94ef48c8e48e3b65b28502452dceffffffffffffffff02e0" +
|
||||
"673500000000001976a914686dd149a79b4a559d561fbc39" +
|
||||
"6d3e3c6628b98d88ace86ef102000000001976a914ac3f99" +
|
||||
"5655e81b875b38b64351d6f896ddbfc68588ac0000000000" +
|
||||
"000000"
|
||||
testSimpleCoinTxHash = "df280b66ce73fbd3713fe280e24bfa8bb21a7ccdfc81829d48bf1e16f8226310"
|
||||
testSimpleCoinTxHex = "0100000001A214A110F79E4ABE073865EA5B3745C6E82C91" +
|
||||
"3BAD44BE70652804A5E4003B0A010000008C493046022100" +
|
||||
"EDD18A69664EFA57264BE207100C203E6CADE1888CBB88A0" +
|
||||
"AD748548256BB2F0022100F1027DC2E6C7F248D78AF1DD90" +
|
||||
"027B5B7D8EC563BB62AA85D4E74D6376F3868C0141048F37" +
|
||||
"57B65ED301ABD1B0E8942D1AB5B50594D3314CFF0299F300" +
|
||||
"C696376A0A9BF72E74710A8AF7A5372D4AF4BB519E2701A0" +
|
||||
"94EF48C8E48E3B65B28502452DCEFFFFFFFFFFFFFFFF02E0" +
|
||||
"673500000000001976A914686DD149A79B4A559D561FBC39" +
|
||||
"6D3E3C6628B98D88ACE86EF102000000001976A914AC3F99" +
|
||||
"5655E81B875B38B64351D6F896DDBFC68588AC0000000000" +
|
||||
"000000010000000000000000"
|
||||
testSimpleCoinTxValue0 = util.Amount(3500000)
|
||||
testSimpleCoinTxValueAge0 = int64(testSimpleCoinTxValue0) * testSimpleCoinNumConfs
|
||||
testSimpleCoinTxPkScript0Hex = "76a914686dd149a79b4a559d561fbc396d3e3c6628b98d88ac"
|
||||
|
@ -35,7 +35,7 @@ func TestTx(t *testing.T) {
|
||||
}
|
||||
|
||||
// Hash for block 100,000 transaction 0.
|
||||
wantHashStr := "8913f1fa776ba67b1bffc156788caa41d914f9d2c90a864421259e5977749669"
|
||||
wantHashStr := "4f2a5f1e00034ed3222e0e7fae8485ad3154d40b21b1c1b64ec74ce389a1bb1d"
|
||||
wantHash, err := daghash.NewHashFromStr(wantHashStr)
|
||||
if err != nil {
|
||||
t.Errorf("NewHashFromStr: %v", err)
|
||||
|
2
util/txsort/testdata/bip69-1.hex
vendored
2
util/txsort/testdata/bip69-1.hex
vendored
File diff suppressed because one or more lines are too long
2
util/txsort/testdata/bip69-2.hex
vendored
2
util/txsort/testdata/bip69-2.hex
vendored
@ -1 +1 @@
|
||||
010000000255605DC6F5C3DC148B6DA58442B0B2CD422BE385EAB2EBEA4119EE9C268D28350000000049483045022100AA46504BAA86DF8A33B1192B1B9367B4D729DC41E389F2C04F3E5C7F0559AAE702205E82253A54BF5C4F65B7428551554B2045167D6D206DFE6A2E198127D3F7DF1501FFFFFFFFFFFFFFFF55605DC6F5C3DC148B6DA58442B0B2CD422BE385EAB2EBEA4119EE9C268D2835010000004847304402202329484C35FA9D6BB32A55A70C0982F606CE0E3634B69006138683BCD12CBB6602200C28FEB1E2555C3210F1DDDB299738B4FF8BBE9667B68CB8764B5AC17B7ADF0001FFFFFFFFFFFFFFFF0200E1F505000000004341046A0765B5865641CE08DD39690AADE26DFBF5511430CA428A3089261361CEF170E3929A68AEE3D8D4848B0C5111B0A37B82B86AD559FD2A745B44D8E8D9DFDC0CAC00180D8F000000004341044A656F065871A353F216CA26CEF8DDE2F03E8C16202D2E8AD769F02032CB86A5EB5E56842E92E19141D60A01928F8DD2C875A390F67C1F6C94CFC617C0EA45AFAC0000000000000000
|
||||
010000000255605DC6F5C3DC148B6DA58442B0B2CD422BE385EAB2EBEA4119EE9C268D28350000000049483045022100AA46504BAA86DF8A33B1192B1B9367B4D729DC41E389F2C04F3E5C7F0559AAE702205E82253A54BF5C4F65B7428551554B2045167D6D206DFE6A2E198127D3F7DF1501FFFFFFFFFFFFFFFF55605DC6F5C3DC148B6DA58442B0B2CD422BE385EAB2EBEA4119EE9C268D2835010000004847304402202329484C35FA9D6BB32A55A70C0982F606CE0E3634B69006138683BCD12CBB6602200C28FEB1E2555C3210F1DDDB299738B4FF8BBE9667B68CB8764B5AC17B7ADF0001FFFFFFFFFFFFFFFF0200E1F505000000004341046A0765B5865641CE08DD39690AADE26DFBF5511430CA428A3089261361CEF170E3929A68AEE3D8D4848B0C5111B0A37B82B86AD559FD2A745B44D8E8D9DFDC0CAC00180D8F000000004341044A656F065871A353F216CA26CEF8DDE2F03E8C16202D2E8AD769F02032CB86A5EB5E56842E92E19141D60A01928F8DD2C875A390F67C1F6C94CFC617C0EA45AFAC00000000000000000100000000000000
|
2
util/txsort/testdata/bip69-3.hex
vendored
2
util/txsort/testdata/bip69-3.hex
vendored
@ -1 +1 @@
|
||||
0100000001d992e5a888a86d4c7a6a69167a4728ee69497509740fc5f456a24528c340219a000000008b483045022100f0519bdc9282ff476da1323b8ef7ffe33f495c1a8d52cc522b437022d83f6a230220159b61d197fbae01b4a66622a23bc3f1def65d5fa24efd5c26fa872f3a246b8e014104839f9023296a1fabb133140128ca2709f6818c7d099491690bd8ac0fd55279def6a2ceb6ab7b5e4a71889b6e739f09509565eec789e86886f6f936fa42097adeffffffffffffffff02000fe208010000001976a914948c765a6914d43f2a7ac177da2c2f6b52de3d7c88ac00e32321000000001976a9140c34f4e29ab5a615d5ea28d4817f12b137d62ed588ac0000000000000000
|
||||
0100000001d992e5a888a86d4c7a6a69167a4728ee69497509740fc5f456a24528c340219a000000008b483045022100f0519bdc9282ff476da1323b8ef7ffe33f495c1a8d52cc522b437022d83f6a230220159b61d197fbae01b4a66622a23bc3f1def65d5fa24efd5c26fa872f3a246b8e014104839f9023296a1fabb133140128ca2709f6818c7d099491690bd8ac0fd55279def6a2ceb6ab7b5e4a71889b6e739f09509565eec789e86886f6f936fa42097adeffffffffffffffff02000fe208010000001976a914948c765a6914d43f2a7ac177da2c2f6b52de3d7c88ac00e32321000000001976a9140c34f4e29ab5a615d5ea28d4817f12b137d62ed588ac00000000000000000100000000000000
|
2
util/txsort/testdata/bip69-4.hex
vendored
2
util/txsort/testdata/bip69-4.hex
vendored
@ -1 +1 @@
|
||||
01000000059daf0abe7a92618546a9dbcfd65869b6178c66ec21ccfda878c1175979cfd9ef000000004a493046022100c2f7f25be5de6ce88ac3c1a519514379e91f39b31ddff279a3db0b1a229b708b022100b29efbdbd9837cc6a6c7318aa4900ed7e4d65662c34d1622a2035a3a5534a99a01ffffffffffffffffd516330ebdf075948da56db13d22632a4fb941122df2884397dda45d451acefb0000000048473044022051243debe6d4f2b433bee0cee78c5c4073ead0e3bde54296dbed6176e128659c022044417bfe16f44eb7b6eb0cdf077b9ce972a332e15395c09ca5e4f602958d266101ffffffffffffffffe1f5aa33961227b3c344e57179417ce01b7ccd421117fe2336289b70489883f900000000484730440220593252bb992ce3c85baf28d6e3aa32065816271d2c822398fe7ee28a856bc943022066d429dd5025d3c86fd8fd8a58e183a844bd94aa312cefe00388f57c85b0ca3201ffffffffffffffffe207e83718129505e6a7484831442f668164ae659fddb82e9e5421a081fb90d50000000049483045022067cf27eb733e5bcae412a586b25a74417c237161a084167c2a0b439abfebdcb2022100efcc6baa6824b4c5205aa967e0b76d31abf89e738d4b6b014e788c9a8cccaf0c01ffffffffffffffffe23b8d9d80a9e9d977fab3c94dbe37befee63822443c3ec5ae5a713ede66c3940000000049483045022020f2eb35036666b1debe0d1d2e77a36d5d9c4e96c1dba23f5100f193dbf524790221008ce79bc1321fb4357c6daee818038d41544749127751726e46b2b320c8b565a201ffffffffffffffff0200ba1dd2050000001976a914366a27645806e817a6cd40bc869bdad92fe5509188ac40420f00000000001976a914ee8bd501094a7d5ca318da2506de35e1cb025ddc88ac0000000000000000
|
||||
01000000059daf0abe7a92618546a9dbcfd65869b6178c66ec21ccfda878c1175979cfd9ef000000004a493046022100c2f7f25be5de6ce88ac3c1a519514379e91f39b31ddff279a3db0b1a229b708b022100b29efbdbd9837cc6a6c7318aa4900ed7e4d65662c34d1622a2035a3a5534a99a01ffffffffffffffffd516330ebdf075948da56db13d22632a4fb941122df2884397dda45d451acefb0000000048473044022051243debe6d4f2b433bee0cee78c5c4073ead0e3bde54296dbed6176e128659c022044417bfe16f44eb7b6eb0cdf077b9ce972a332e15395c09ca5e4f602958d266101ffffffffffffffffe1f5aa33961227b3c344e57179417ce01b7ccd421117fe2336289b70489883f900000000484730440220593252bb992ce3c85baf28d6e3aa32065816271d2c822398fe7ee28a856bc943022066d429dd5025d3c86fd8fd8a58e183a844bd94aa312cefe00388f57c85b0ca3201ffffffffffffffffe207e83718129505e6a7484831442f668164ae659fddb82e9e5421a081fb90d50000000049483045022067cf27eb733e5bcae412a586b25a74417c237161a084167c2a0b439abfebdcb2022100efcc6baa6824b4c5205aa967e0b76d31abf89e738d4b6b014e788c9a8cccaf0c01ffffffffffffffffe23b8d9d80a9e9d977fab3c94dbe37befee63822443c3ec5ae5a713ede66c3940000000049483045022020f2eb35036666b1debe0d1d2e77a36d5d9c4e96c1dba23f5100f193dbf524790221008ce79bc1321fb4357c6daee818038d41544749127751726e46b2b320c8b565a201ffffffffffffffff0200ba1dd2050000001976a914366a27645806e817a6cd40bc869bdad92fe5509188ac40420f00000000001976a914ee8bd501094a7d5ca318da2506de35e1cb025ddc88ac00000000000000000100000000000000
|
2
util/txsort/testdata/bip69-5.hex
vendored
2
util/txsort/testdata/bip69-5.hex
vendored
@ -1 +1 @@
|
||||
01000000011f636d0003f673b3aeea4971daef16b8eed784cf6e8019a5ae7da4985fbb06e5000000008a47304402205103941e2b11e746dfa817888d422f6e7f4d16dbbfb8ffa61d15ffb924a84b8802202fe861b0f23f17139d15a3374bfc6c7196d371f3d1a324e31cc0aadbba87e53c0141049e7e1b251a7e26cae9ee7553b278ef58ef3c28b4b20134d51b747d9b18b0a19b94b66cef320e2549dec0ea3d725cb4c742f368928b1fb74b4603e24a1e262c80ffffffffffffffff0240420f00000000001976a914bcfa0e27218a7c97257b351b03a9eac95c25a23988ac40420f00000000001976a9140c6a68f20bafc678164d171ee4f077adfa9b091688ac0000000000000000
|
||||
01000000011f636d0003f673b3aeea4971daef16b8eed784cf6e8019a5ae7da4985fbb06e5000000008a47304402205103941e2b11e746dfa817888d422f6e7f4d16dbbfb8ffa61d15ffb924a84b8802202fe861b0f23f17139d15a3374bfc6c7196d371f3d1a324e31cc0aadbba87e53c0141049e7e1b251a7e26cae9ee7553b278ef58ef3c28b4b20134d51b747d9b18b0a19b94b66cef320e2549dec0ea3d725cb4c742f368928b1fb74b4603e24a1e262c80ffffffffffffffff0240420f00000000001976a914bcfa0e27218a7c97257b351b03a9eac95c25a23988ac40420f00000000001976a9140c6a68f20bafc678164d171ee4f077adfa9b091688ac00000000000000000100000000000000
|
@ -28,36 +28,36 @@ func TestSort(t *testing.T) {
|
||||
name: "first test case from BIP 69 - sorts inputs only, based on hash",
|
||||
hexFile: "bip69-1.hex",
|
||||
isSorted: false,
|
||||
unsortedHash: "652c30fa452b4706db2f4630a99e2e4d5205bc4724b758e02e7f3e5b772f2454",
|
||||
sortedHash: "cb0d27e995be2d7670c172dd2c2b155cdeb5d6c60e8b13b3e398667a451279e8",
|
||||
unsortedHash: "55721464fe5511e70792da14d7c4f20f6e81d5e7197919e536d0598796daaef3",
|
||||
sortedHash: "573054025c067ab92e3e8b66cf25d16dbb8ab4ff9e9ef9ece79d2aee83f06785",
|
||||
},
|
||||
{
|
||||
name: "second test case from BIP 69 - already sorted",
|
||||
hexFile: "bip69-2.hex",
|
||||
isSorted: true,
|
||||
unsortedHash: "1b4c7d54847f0a07a018816894cd6ee172802e4166ad0a705ad7c84ae531a2b7",
|
||||
sortedHash: "1b4c7d54847f0a07a018816894cd6ee172802e4166ad0a705ad7c84ae531a2b7",
|
||||
unsortedHash: "b9ce1181a9f94375000c9a49fc097a9abe9eb85a0f2e6792e1ec0ac24f72172b",
|
||||
sortedHash: "b9ce1181a9f94375000c9a49fc097a9abe9eb85a0f2e6792e1ec0ac24f72172b",
|
||||
},
|
||||
{
|
||||
name: "block 100001 tx[1] - sorts outputs only, based on amount",
|
||||
hexFile: "bip69-3.hex",
|
||||
isSorted: false,
|
||||
unsortedHash: "fe297f705cf3a08dd398a85187060b45688008c658afa364384931d8cb091e34",
|
||||
sortedHash: "487caaf688db44e54ed2a0dc0d5b665ad13c399259abd1e8abce1f7e762a52d2",
|
||||
unsortedHash: "a1fd1029514fb555ecaa6126849d66a19c4239b2a77bdace6f6ef7db3cc23f30",
|
||||
sortedHash: "4234b089ff83ec954b76e8b56449c095718124ebedd4cf8642d49f02ae55ade2",
|
||||
},
|
||||
{
|
||||
name: "block 100001 tx[2] - sorts both inputs and outputs",
|
||||
hexFile: "bip69-4.hex",
|
||||
isSorted: false,
|
||||
unsortedHash: "1132a25b7a18ede0e03dd8472313357512c788faf31da4225579436432b2606f",
|
||||
sortedHash: "f63e7e1a71c39970e9c92a1c3fdfd50269819431249d5c560213eb270e48371f",
|
||||
unsortedHash: "d2eb3b56e3be83886dc5ee5789c332ba77f0f3f53abe98d306c1b2e9c25045a2",
|
||||
sortedHash: "280567fe8d4cda60aa1d1b6ca87dd5944d761e8dee72a704af71365696988cda",
|
||||
},
|
||||
{
|
||||
name: "block 100998 tx[6] - sorts outputs only, based on output script",
|
||||
hexFile: "bip69-5.hex",
|
||||
isSorted: false,
|
||||
unsortedHash: "712433780097a8966d5824fb3ea2a87fc0de080d5131d3257dc393f81ba40ce3",
|
||||
sortedHash: "6bdc745db166942bba7a31ae16ae447897d2223a7d16c057db9ee9f285fea1ef",
|
||||
unsortedHash: "5c83c1b03b7a1c80a44686323ea17d5bc60a976efb5a3de116cb99cac6ec2557",
|
||||
sortedHash: "23c0abbbd17ca34980c9330e10b2c9230d72cec5aba38306ea676bbfa789a125",
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -75,10 +75,10 @@ func TestBlockHeaderWire(t *testing.T) {
|
||||
0x72, 0xff, 0x3d, 0x8e, 0xdb, 0xbb, 0x2d, 0xe0,
|
||||
0xbf, 0xa6, 0x7b, 0x13, 0x97, 0x4b, 0xb9, 0x91,
|
||||
0x0d, 0x11, 0x6d, 0x5c, 0xbd, 0x86, 0x3e, 0x68,
|
||||
0x3b, 0xa3, 0xed, 0xfd, 0x7a, 0x7b, 0x12, 0xb2, // MerkleRoot
|
||||
0x7a, 0xc7, 0x2c, 0x3e, 0x67, 0x76, 0x8f, 0x61,
|
||||
0x7f, 0xc8, 0x1b, 0xc3, 0x88, 0x8a, 0x51, 0x32,
|
||||
0x3a, 0x9f, 0xb8, 0xaa, 0x4b, 0x1e, 0x5e, 0x4a,
|
||||
0x4a, 0x5e, 0x1e, 0x4b, 0xaa, 0xb8, 0x9f, 0x3a, // MerkleRoot
|
||||
0x32, 0x51, 0x8a, 0x88, 0xc3, 0x1b, 0xc8, 0x7f,
|
||||
0x61, 0x8f, 0x76, 0x67, 0x3e, 0x2c, 0xc7, 0x7a,
|
||||
0xb2, 0x12, 0x7b, 0x7a, 0xfd, 0xed, 0xa3, 0x3b,
|
||||
0x29, 0xab, 0x5f, 0x49, 0x00, 0x00, 0x00, 0x00, // Timestamp
|
||||
0xff, 0xff, 0x00, 0x1d, // Bits
|
||||
0xf3, 0xe0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, // Fake Nonce. TODO: (Ori) Replace to a real nonce
|
||||
@ -213,10 +213,10 @@ func TestBlockHeaderSerialize(t *testing.T) {
|
||||
0x72, 0xff, 0x3d, 0x8e, 0xdb, 0xbb, 0x2d, 0xe0,
|
||||
0xbf, 0xa6, 0x7b, 0x13, 0x97, 0x4b, 0xb9, 0x91,
|
||||
0x0d, 0x11, 0x6d, 0x5c, 0xbd, 0x86, 0x3e, 0x68,
|
||||
0x3b, 0xa3, 0xed, 0xfd, 0x7a, 0x7b, 0x12, 0xb2, // MerkleRoot
|
||||
0x7a, 0xc7, 0x2c, 0x3e, 0x67, 0x76, 0x8f, 0x61,
|
||||
0x7f, 0xc8, 0x1b, 0xc3, 0x88, 0x8a, 0x51, 0x32,
|
||||
0x3a, 0x9f, 0xb8, 0xaa, 0x4b, 0x1e, 0x5e, 0x4a,
|
||||
0x4a, 0x5e, 0x1e, 0x4b, 0xaa, 0xb8, 0x9f, 0x3a, // MerkleRoot
|
||||
0x32, 0x51, 0x8a, 0x88, 0xc3, 0x1b, 0xc8, 0x7f,
|
||||
0x61, 0x8f, 0x76, 0x67, 0x3e, 0x2c, 0xc7, 0x7a,
|
||||
0xb2, 0x12, 0x7b, 0x7a, 0xfd, 0xed, 0xa3, 0x3b,
|
||||
0x29, 0xab, 0x5f, 0x49, 0x00, 0x00, 0x00, 0x00, // Timestamp
|
||||
0xff, 0xff, 0x00, 0x1d, // Bits
|
||||
0xf3, 0xe0, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, // Fake Nonce. TODO: (Ori) Replace to a real nonce
|
||||
|
@ -37,10 +37,10 @@ var simNetGenesisHash = daghash.Hash([daghash.HashSize]byte{ // Make go vet happ
|
||||
// mainNetGenesisMerkleRoot is the hash of the first transaction in the genesis
|
||||
// block for the main network.
|
||||
var mainNetGenesisMerkleRoot = daghash.Hash([daghash.HashSize]byte{ // Make go vet happy.
|
||||
0x3b, 0xa3, 0xed, 0xfd, 0x7a, 0x7b, 0x12, 0xb2,
|
||||
0x7a, 0xc7, 0x2c, 0x3e, 0x67, 0x76, 0x8f, 0x61,
|
||||
0x7f, 0xc8, 0x1b, 0xc3, 0x88, 0x8a, 0x51, 0x32,
|
||||
0x3a, 0x9f, 0xb8, 0xaa, 0x4b, 0x1e, 0x5e, 0x4a,
|
||||
0x4a, 0x5e, 0x1e, 0x4b, 0xaa, 0xb8, 0x9f, 0x3a,
|
||||
0x32, 0x51, 0x8a, 0x88, 0xc3, 0x1b, 0xc8, 0x7f,
|
||||
0x61, 0x8f, 0x76, 0x67, 0x3e, 0x2c, 0xc7, 0x7a,
|
||||
0xb2, 0x12, 0x7b, 0x7a, 0xfd, 0xed, 0xa3, 0x3b,
|
||||
})
|
||||
|
||||
// fakeRandReader implements the io.Reader interface and is used to force
|
||||
|
@ -91,11 +91,11 @@ func TestMessage(t *testing.T) {
|
||||
{msgGetAddr, msgGetAddr, pver, MainNet, 24},
|
||||
{msgAddr, msgAddr, pver, MainNet, 25},
|
||||
{msgGetBlocks, msgGetBlocks, pver, MainNet, 61},
|
||||
{msgBlock, msgBlock, pver, MainNet, 288},
|
||||
{msgBlock, msgBlock, pver, MainNet, 296},
|
||||
{msgInv, msgInv, pver, MainNet, 25},
|
||||
{msgGetData, msgGetData, pver, MainNet, 25},
|
||||
{msgNotFound, msgNotFound, pver, MainNet, 25},
|
||||
{msgTx, msgTx, pver, MainNet, 38},
|
||||
{msgTx, msgTx, pver, MainNet, 46},
|
||||
{msgPing, msgPing, pver, MainNet, 32},
|
||||
{msgPong, msgPong, pver, MainNet, 32},
|
||||
{msgGetHeaders, msgGetHeaders, pver, MainNet, 61},
|
||||
|
@ -72,7 +72,7 @@ func TestBlock(t *testing.T) {
|
||||
// hashes from a block accurately.
|
||||
func TestBlockTxHashes(t *testing.T) {
|
||||
// Block 1, transaction 1 hash.
|
||||
hashStr := "b7c3332bc138e2c9429818f5fed500bcc1746544218772389054dc8047d7cd3f"
|
||||
hashStr := "603ea191aecb5809c78790a0bd58293086c1b19118e7251a38680dd9e1dc3b32"
|
||||
wantHash, err := daghash.NewHashFromStr(hashStr)
|
||||
if err != nil {
|
||||
t.Errorf("NewHashFromStr: %v", err)
|
||||
@ -93,7 +93,7 @@ func TestBlockTxHashes(t *testing.T) {
|
||||
// TestBlockHash tests the ability to generate the hash of a block accurately.
|
||||
func TestBlockHash(t *testing.T) {
|
||||
// Block 1 hash.
|
||||
hashStr := "5d8486ede1953cb1bc91720f10421ae670ec66565f1cc0b889fba125f79d5de3"
|
||||
hashStr := "f10122ba81929ca2bc907541ebb20302122ce83a24ff9124c9e36402ecd837b7"
|
||||
wantHash, err := daghash.NewHashFromStr(hashStr)
|
||||
if err != nil {
|
||||
t.Errorf("NewHashFromStr: %v", err)
|
||||
@ -532,7 +532,8 @@ var blockOne = MsgBlock{
|
||||
},
|
||||
},
|
||||
},
|
||||
LockTime: 0,
|
||||
LockTime: 0,
|
||||
SubNetworkID: SubNetworkDAGCoin,
|
||||
},
|
||||
},
|
||||
}
|
||||
@ -549,10 +550,10 @@ var blockOneBytes = []byte{
|
||||
0x72, 0xff, 0x3d, 0x8e, 0xdb, 0xbb, 0x2d, 0xe0,
|
||||
0xbf, 0xa6, 0x7b, 0x13, 0x97, 0x4b, 0xb9, 0x91,
|
||||
0x0d, 0x11, 0x6d, 0x5c, 0xbd, 0x86, 0x3e, 0x68,
|
||||
0x3b, 0xa3, 0xed, 0xfd, 0x7a, 0x7b, 0x12, 0xb2, // MerkleRoot
|
||||
0x7a, 0xc7, 0x2c, 0x3e, 0x67, 0x76, 0x8f, 0x61,
|
||||
0x7f, 0xc8, 0x1b, 0xc3, 0x88, 0x8a, 0x51, 0x32,
|
||||
0x3a, 0x9f, 0xb8, 0xaa, 0x4b, 0x1e, 0x5e, 0x4a,
|
||||
0x4a, 0x5e, 0x1e, 0x4b, 0xaa, 0xb8, 0x9f, 0x3a, // MerkleRoot
|
||||
0x32, 0x51, 0x8a, 0x88, 0xc3, 0x1b, 0xc8, 0x7f,
|
||||
0x61, 0x8f, 0x76, 0x67, 0x3e, 0x2c, 0xc7, 0x7a,
|
||||
0xb2, 0x12, 0x7b, 0x7a, 0xfd, 0xed, 0xa3, 0x3b,
|
||||
0x61, 0xbc, 0x66, 0x49, 0x00, 0x00, 0x00, 0x00, // Timestamp
|
||||
0xff, 0xff, 0x00, 0x1d, // Bits
|
||||
0x01, 0xe3, 0x62, 0x99, 0x00, 0x00, 0x00, 0x00, // Fake Nonce. TODO: (Ori) Replace to a real nonce
|
||||
@ -582,9 +583,10 @@ var blockOneBytes = []byte{
|
||||
0xee, // 65-byte uncompressed public key
|
||||
0xac, // OP_CHECKSIG
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Lock time
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Subnetwork ID
|
||||
}
|
||||
|
||||
// Transaction location information for block one transactions.
|
||||
var blockOneTxLocs = []TxLoc{
|
||||
{TxStart: 122, TxLen: 142},
|
||||
{TxStart: 122, TxLen: 150},
|
||||
}
|
||||
|
@ -90,10 +90,10 @@ func TestHeadersWire(t *testing.T) {
|
||||
0x72, 0xff, 0x3d, 0x8e, 0xdb, 0xbb, 0x2d, 0xe0,
|
||||
0xbf, 0xa6, 0x7b, 0x13, 0x97, 0x4b, 0xb9, 0x91,
|
||||
0x0d, 0x11, 0x6d, 0x5c, 0xbd, 0x86, 0x3e, 0x68,
|
||||
0x3b, 0xa3, 0xed, 0xfd, 0x7a, 0x7b, 0x12, 0xb2, // MerkleRoot
|
||||
0x7a, 0xc7, 0x2c, 0x3e, 0x67, 0x76, 0x8f, 0x61,
|
||||
0x7f, 0xc8, 0x1b, 0xc3, 0x88, 0x8a, 0x51, 0x32,
|
||||
0x3a, 0x9f, 0xb8, 0xaa, 0x4b, 0x1e, 0x5e, 0x4a,
|
||||
0x4a, 0x5e, 0x1e, 0x4b, 0xaa, 0xb8, 0x9f, 0x3a, // MerkleRoot
|
||||
0x32, 0x51, 0x8a, 0x88, 0xc3, 0x1b, 0xc8, 0x7f,
|
||||
0x61, 0x8f, 0x76, 0x67, 0x3e, 0x2c, 0xc7, 0x7a,
|
||||
0xb2, 0x12, 0x7b, 0x7a, 0xfd, 0xed, 0xa3, 0x3b,
|
||||
0x61, 0xbc, 0x66, 0x49, 0x00, 0x00, 0x00, 0x00, // Timestamp
|
||||
0xff, 0xff, 0x00, 0x1d, // Bits
|
||||
0x01, 0xe3, 0x62, 0x99, 0x00, 0x00, 0x00, 0x00, // Fake Nonce. TODO: (Ori) Replace to a real nonce
|
||||
|
141
wire/msgtx.go
141
wire/msgtx.go
@ -6,6 +6,7 @@ package wire
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"fmt"
|
||||
"io"
|
||||
"math"
|
||||
@ -94,6 +95,15 @@ const (
|
||||
// peers. Thus, the peak usage of the free list is 12,500 * 512 =
|
||||
// 6,400,000 bytes.
|
||||
freeListMaxItems = 12500
|
||||
|
||||
// SubNetworkSupportsAll is the sub network id that is used to signal to peers that you support all sub-networks
|
||||
SubNetworkSupportsAll = 0
|
||||
|
||||
// SubNetworkDAGCoin is the default sub network which is used for transactions without related payload data
|
||||
SubNetworkDAGCoin = 1
|
||||
|
||||
// SubNetworkRegistry is the sub network which is used for adding new sub networks to the registry
|
||||
SubNetworkRegistry = 2
|
||||
)
|
||||
|
||||
// scriptFreeList defines a free list of byte slices (up to the maximum number
|
||||
@ -242,10 +252,13 @@ func NewTxOut(value uint64, pkScript []byte) *TxOut {
|
||||
// Use the AddTxIn and AddTxOut functions to build up the list of transaction
|
||||
// inputs and outputs.
|
||||
type MsgTx struct {
|
||||
Version int32
|
||||
TxIn []*TxIn
|
||||
TxOut []*TxOut
|
||||
LockTime uint64
|
||||
Version int32
|
||||
TxIn []*TxIn
|
||||
TxOut []*TxOut
|
||||
LockTime uint64
|
||||
SubNetworkID uint64
|
||||
Gas uint64
|
||||
Payload []byte
|
||||
}
|
||||
|
||||
// AddTxIn adds a transaction input to the message.
|
||||
@ -275,10 +288,17 @@ func (msg *MsgTx) Copy() *MsgTx {
|
||||
// Create new tx and start by copying primitive values and making space
|
||||
// for the transaction inputs and outputs.
|
||||
newTx := MsgTx{
|
||||
Version: msg.Version,
|
||||
TxIn: make([]*TxIn, 0, len(msg.TxIn)),
|
||||
TxOut: make([]*TxOut, 0, len(msg.TxOut)),
|
||||
LockTime: msg.LockTime,
|
||||
Version: msg.Version,
|
||||
TxIn: make([]*TxIn, 0, len(msg.TxIn)),
|
||||
TxOut: make([]*TxOut, 0, len(msg.TxOut)),
|
||||
LockTime: msg.LockTime,
|
||||
SubNetworkID: msg.SubNetworkID,
|
||||
Gas: msg.Gas,
|
||||
}
|
||||
|
||||
if msg.Payload != nil {
|
||||
newTx.Payload = make([]byte, len(msg.Payload))
|
||||
copy(newTx.Payload, msg.Payload)
|
||||
}
|
||||
|
||||
// Deep copy the old TxIn data.
|
||||
@ -435,6 +455,46 @@ func (msg *MsgTx) BtcDecode(r io.Reader, pver uint32) error {
|
||||
return err
|
||||
}
|
||||
|
||||
msg.SubNetworkID, err = binarySerializer.Uint64(r, littleEndian)
|
||||
if err != nil {
|
||||
returnScriptBuffers()
|
||||
return err
|
||||
}
|
||||
|
||||
if msg.SubNetworkID == SubNetworkSupportsAll {
|
||||
str := fmt.Sprintf("%v is a reserved sub network and cannot be used as part of a transaction", msg.SubNetworkID)
|
||||
return messageError("MsgTx.BtcDecode", str)
|
||||
}
|
||||
|
||||
if msg.SubNetworkID != SubNetworkDAGCoin {
|
||||
msg.Gas, err = binarySerializer.Uint64(r, littleEndian)
|
||||
if err != nil {
|
||||
returnScriptBuffers()
|
||||
return err
|
||||
}
|
||||
|
||||
isRegistrySubNetwork := msg.SubNetworkID == SubNetworkRegistry
|
||||
|
||||
if isRegistrySubNetwork && msg.Gas != 0 {
|
||||
str := fmt.Sprintf("Transactions from subnetwork %v should have 0 gas", msg.SubNetworkID)
|
||||
return messageError("MsgTx.BtcDecode", str)
|
||||
}
|
||||
|
||||
payloadLength, err := ReadVarInt(r, pver)
|
||||
if err != nil {
|
||||
returnScriptBuffers()
|
||||
return err
|
||||
}
|
||||
|
||||
if isRegistrySubNetwork && payloadLength != 8 {
|
||||
str := fmt.Sprintf("For registry sub network the payload should always be uint64 (8 bytes length)")
|
||||
return messageError("MsgTx.BtcDecode", str)
|
||||
}
|
||||
|
||||
msg.Payload = make([]byte, payloadLength)
|
||||
_, err = io.ReadFull(r, msg.Payload)
|
||||
}
|
||||
|
||||
// Create a single allocation to house all of the scripts and set each
|
||||
// input signature script and output public key script to the
|
||||
// appropriate subslice of the overall contiguous buffer. Then, return
|
||||
@ -540,7 +600,41 @@ func (msg *MsgTx) BtcEncode(w io.Writer, pver uint32) error {
|
||||
}
|
||||
}
|
||||
|
||||
return binarySerializer.PutUint64(w, littleEndian, msg.LockTime)
|
||||
err = binarySerializer.PutUint64(w, littleEndian, msg.LockTime)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = binarySerializer.PutUint64(w, littleEndian, msg.SubNetworkID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if msg.SubNetworkID != SubNetworkDAGCoin {
|
||||
if msg.SubNetworkID == SubNetworkRegistry && msg.Gas != 0 {
|
||||
str := fmt.Sprintf("Transactions from subnetwork %v should have 0 gas", msg.SubNetworkID)
|
||||
return messageError("MsgTx.BtcEncode", str)
|
||||
}
|
||||
|
||||
err = binarySerializer.PutUint64(w, littleEndian, msg.Gas)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = WriteVarInt(w, pver, uint64(len(msg.Payload)))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
w.Write(msg.Payload)
|
||||
} else if msg.Payload != nil {
|
||||
str := fmt.Sprintf("Transactions from subnetwork %v should have <nil> payload", msg.SubNetworkID)
|
||||
return messageError("MsgTx.BtcEncode", str)
|
||||
} else if msg.Gas != 0 {
|
||||
str := fmt.Sprintf("Transactions from subnetwork %v should have 0 gas", msg.SubNetworkID)
|
||||
return messageError("MsgTx.BtcEncode", str)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Serialize encodes the transaction to w using a format that suitable for
|
||||
@ -563,11 +657,17 @@ func (msg *MsgTx) Serialize(w io.Writer) error {
|
||||
// SerializeSize returns the number of bytes it would take to serialize the
|
||||
// the transaction.
|
||||
func (msg *MsgTx) SerializeSize() int {
|
||||
// Version 4 bytes + LockTime 8 bytes + Serialized varint size for the
|
||||
// number of transaction inputs and outputs.
|
||||
n := 12 + VarIntSerializeSize(uint64(len(msg.TxIn))) +
|
||||
// Version 4 bytes + LockTime 8 bytes + Subnetwork ID 8
|
||||
// bytes + Serialized varint size for the number of transaction
|
||||
// inputs and outputs.
|
||||
n := 20 + VarIntSerializeSize(uint64(len(msg.TxIn))) +
|
||||
VarIntSerializeSize(uint64(len(msg.TxOut)))
|
||||
|
||||
if msg.SubNetworkID != SubNetworkDAGCoin {
|
||||
// Gas 8 bytes + Serialized varint size for the length of the payload
|
||||
n += 8 + VarIntSerializeSize(uint64(len(msg.Payload)))
|
||||
}
|
||||
|
||||
for _, txIn := range msg.TxIn {
|
||||
n += txIn.SerializeSize()
|
||||
}
|
||||
@ -576,6 +676,8 @@ func (msg *MsgTx) SerializeSize() int {
|
||||
n += txOut.SerializeSize()
|
||||
}
|
||||
|
||||
n += len(msg.Payload)
|
||||
|
||||
return n
|
||||
}
|
||||
|
||||
@ -636,12 +738,21 @@ func (msg *MsgTx) PkScriptLocs() []int {
|
||||
// future.
|
||||
func NewMsgTx(version int32) *MsgTx {
|
||||
return &MsgTx{
|
||||
Version: version,
|
||||
TxIn: make([]*TxIn, 0, defaultTxInOutAlloc),
|
||||
TxOut: make([]*TxOut, 0, defaultTxInOutAlloc),
|
||||
Version: version,
|
||||
TxIn: make([]*TxIn, 0, defaultTxInOutAlloc),
|
||||
TxOut: make([]*TxOut, 0, defaultTxInOutAlloc),
|
||||
SubNetworkID: SubNetworkDAGCoin,
|
||||
}
|
||||
}
|
||||
|
||||
func newRegistryMsgTx(version int32, gasLimit uint64) *MsgTx {
|
||||
tx := NewMsgTx(version)
|
||||
tx.SubNetworkID = SubNetworkRegistry
|
||||
tx.Payload = make([]byte, 8)
|
||||
binary.LittleEndian.PutUint64(tx.Payload, gasLimit)
|
||||
return tx
|
||||
}
|
||||
|
||||
// readOutPoint reads the next sequence of bytes from r as an OutPoint.
|
||||
func readOutPoint(r io.Reader, pver uint32, version int32, op *OutPoint) error {
|
||||
_, err := io.ReadFull(r, op.Hash[:])
|
||||
|
@ -130,7 +130,7 @@ func TestTx(t *testing.T) {
|
||||
// TestTxHash tests the ability to generate the hash of a transaction accurately.
|
||||
func TestTxHash(t *testing.T) {
|
||||
// Hash of first transaction from block 113875.
|
||||
hashStr := "768f7e5de1e0a209c9f4e89a5b610d15e888dfe8f32be7f92462edc5815fc025"
|
||||
hashStr := "bc103ee9c89185146ba4e3eb9e936d46acd312cd8d2c5865fa4b0c02e67d0959"
|
||||
wantHash, err := daghash.NewHashFromStr(hashStr)
|
||||
if err != nil {
|
||||
t.Errorf("NewHashFromStr: %v", err)
|
||||
@ -186,6 +186,7 @@ func TestTxWire(t *testing.T) {
|
||||
0x00, // Varint for number of input transactions
|
||||
0x00, // Varint for number of output transactions
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Lock time
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Sub Network ID
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
@ -379,6 +380,35 @@ func TestTxSerialize(t *testing.T) {
|
||||
0x00, // Varint for number of input transactions
|
||||
0x00, // Varint for number of output transactions
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Lock time
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Sub Network ID
|
||||
}
|
||||
|
||||
registryTx := newRegistryMsgTx(1, 16)
|
||||
registryTxEncoded := []byte{
|
||||
0x01, 0x00, 0x00, 0x00, // Version
|
||||
0x00, // Varint for number of input transactions
|
||||
0x00, // Varint for number of output transactions
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Lock time
|
||||
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Sub Network ID
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Gas
|
||||
0x08, // Payload length varint
|
||||
0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Payload / Gas limit
|
||||
}
|
||||
|
||||
subNetworkTx := NewMsgTx(1)
|
||||
subNetworkTx.SubNetworkID = 0xff
|
||||
subNetworkTx.Gas = 5
|
||||
subNetworkTx.Payload = []byte{0, 1, 2}
|
||||
|
||||
subNetworkTxEncoded := []byte{
|
||||
0x01, 0x00, 0x00, 0x00, // Version
|
||||
0x00, // Varint for number of input transactions
|
||||
0x00, // Varint for number of output transactions
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Lock time
|
||||
0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Sub Network ID
|
||||
0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Gas
|
||||
0x03, // Payload length varint
|
||||
0x00, 0x01, 0x02, // Payload
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
@ -395,6 +425,22 @@ func TestTxSerialize(t *testing.T) {
|
||||
nil,
|
||||
},
|
||||
|
||||
// Registry Transaction.
|
||||
{
|
||||
registryTx,
|
||||
registryTx,
|
||||
registryTxEncoded,
|
||||
nil,
|
||||
},
|
||||
|
||||
// Sub Network Transaction.
|
||||
{
|
||||
subNetworkTx,
|
||||
subNetworkTx,
|
||||
subNetworkTxEncoded,
|
||||
nil,
|
||||
},
|
||||
|
||||
// Multiple transactions.
|
||||
{
|
||||
multiTx,
|
||||
@ -511,6 +557,101 @@ func TestTxSerializeErrors(t *testing.T) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
registryTx := NewMsgTx(1)
|
||||
registryTx.SubNetworkID = SubNetworkRegistry
|
||||
registryTx.Gas = 1
|
||||
|
||||
w := bytes.NewBuffer(make([]byte, 0, registryTx.SerializeSize()))
|
||||
err := registryTx.Serialize(w)
|
||||
str := fmt.Sprintf("Transactions from subnetwork %v should have 0 gas", SubNetworkRegistry)
|
||||
expectedErr := messageError("MsgTx.BtcEncode", str)
|
||||
if err == nil || err.Error() != expectedErr.Error() {
|
||||
t.Errorf("TestTxSerializeErrors: expected error %v but got %v", expectedErr, err)
|
||||
}
|
||||
|
||||
dagCoinTx := NewMsgTx(1)
|
||||
dagCoinTx.Gas = 1
|
||||
w = bytes.NewBuffer(make([]byte, 0, registryTx.SerializeSize()))
|
||||
err = dagCoinTx.Serialize(w)
|
||||
|
||||
str = fmt.Sprintf("Transactions from subnetwork %v should have 0 gas", SubNetworkDAGCoin)
|
||||
expectedErr = messageError("MsgTx.BtcEncode", str)
|
||||
if err == nil || err.Error() != expectedErr.Error() {
|
||||
t.Errorf("TestTxSerializeErrors: expected error %v but got %v", expectedErr, err)
|
||||
}
|
||||
|
||||
dagCoinTx.Gas = 0
|
||||
dagCoinTx.Payload = []byte{1, 2, 3}
|
||||
w = bytes.NewBuffer(make([]byte, 0, registryTx.SerializeSize()))
|
||||
err = dagCoinTx.Serialize(w)
|
||||
|
||||
str = fmt.Sprintf("Transactions from subnetwork %v should have <nil> payload", SubNetworkDAGCoin)
|
||||
expectedErr = messageError("MsgTx.BtcEncode", str)
|
||||
if err == nil || err.Error() != expectedErr.Error() {
|
||||
t.Errorf("TestTxSerializeErrors: expected error %v but got %v", expectedErr, err)
|
||||
}
|
||||
|
||||
zeroSubnetworkTxEncoded := []byte{
|
||||
0x01, 0x00, 0x00, 0x00, // Version
|
||||
0x00, // Varint for number of input transactions
|
||||
0x00, // Varint for number of output transactions
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Lock time
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Sub Network ID
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Gas
|
||||
0x08, // Payload length varint
|
||||
0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Payload / Gas limit
|
||||
}
|
||||
|
||||
r := bytes.NewReader(zeroSubnetworkTxEncoded)
|
||||
var tx MsgTx
|
||||
err = tx.Deserialize(r)
|
||||
|
||||
str = fmt.Sprintf("%v is a reserved sub network and cannot be used as part of a transaction", 0)
|
||||
expectedErr = messageError("MsgTx.BtcDecode", str)
|
||||
if err == nil || err.Error() != expectedErr.Error() {
|
||||
t.Errorf("TestTxSerializeErrors: expected error %v but got %v", expectedErr, err)
|
||||
}
|
||||
|
||||
registryWithGasTxEncoded := []byte{
|
||||
0x01, 0x00, 0x00, 0x00, // Version
|
||||
0x00, // Varint for number of input transactions
|
||||
0x00, // Varint for number of output transactions
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Lock time
|
||||
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Sub Network ID
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Gas
|
||||
0x08, // Payload length varint
|
||||
0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Payload / Gas limit
|
||||
}
|
||||
|
||||
r = bytes.NewReader(registryWithGasTxEncoded)
|
||||
err = tx.Deserialize(r)
|
||||
|
||||
str = fmt.Sprintf("Transactions from subnetwork %v should have 0 gas", SubNetworkRegistry)
|
||||
expectedErr = messageError("MsgTx.BtcDecode", str)
|
||||
if err == nil || err.Error() != expectedErr.Error() {
|
||||
t.Errorf("TestTxSerializeErrors: expected error %v but got %v", expectedErr, err)
|
||||
}
|
||||
|
||||
registryWithWrongPayloadTxEncoded := []byte{
|
||||
0x01, 0x00, 0x00, 0x00, // Version
|
||||
0x00, // Varint for number of input transactions
|
||||
0x00, // Varint for number of output transactions
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Lock time
|
||||
0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Sub Network ID
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Gas
|
||||
0x03, // Payload length varint
|
||||
0x01, 0x02, 0x03, // Payload / Gas limit
|
||||
}
|
||||
|
||||
r = bytes.NewReader(registryWithWrongPayloadTxEncoded)
|
||||
err = tx.Deserialize(r)
|
||||
|
||||
str = fmt.Sprintf("For registry sub network the payload should always be uint64 (8 bytes length)")
|
||||
expectedErr = messageError("MsgTx.BtcDecode", str)
|
||||
if err == nil || err.Error() != expectedErr.Error() {
|
||||
t.Errorf("TestTxSerializeErrors: expected error %v but got %v", expectedErr, err)
|
||||
}
|
||||
}
|
||||
|
||||
// TestTxOverflowErrors performs tests to ensure deserializing transactions
|
||||
@ -621,10 +762,10 @@ func TestTxSerializeSize(t *testing.T) {
|
||||
size int // Expected serialized size
|
||||
}{
|
||||
// No inputs or outpus.
|
||||
{noTx, 14},
|
||||
{noTx, 22},
|
||||
|
||||
// Transcaction with an input and an output.
|
||||
{multiTx, 218},
|
||||
{multiTx, 226},
|
||||
}
|
||||
|
||||
t.Logf("Running %d tests", len(tests))
|
||||
@ -756,7 +897,8 @@ var multiTx = &MsgTx{
|
||||
},
|
||||
},
|
||||
},
|
||||
LockTime: 0,
|
||||
LockTime: 0,
|
||||
SubNetworkID: SubNetworkDAGCoin,
|
||||
}
|
||||
|
||||
// multiTxEncoded is the wire encoded bytes for multiTx using protocol version
|
||||
@ -800,6 +942,7 @@ var multiTxEncoded = []byte{
|
||||
0xa6, // 65-byte signature
|
||||
0xac, // OP_CHECKSIG
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Lock time
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Sub Network ID
|
||||
}
|
||||
|
||||
// multiTxPkScriptLocs is the location information for the public key scripts
|
||||
|
Loading…
x
Reference in New Issue
Block a user