mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08:33 +00:00
Merge pull request #32 from daglabs/dev-31-convert-time-int64
Dev 31 convert time to int64
This commit is contained in:
commit
226abbc37b
2
.gitignore
vendored
2
.gitignore
vendored
@ -37,4 +37,4 @@ _testmain.go
|
||||
.idea
|
||||
.vscode
|
||||
debug
|
||||
debug.test
|
||||
debug.test
|
@ -472,7 +472,7 @@ func (b *BlockDAG) calcSequenceLock(node *blockNode, tx *btcutil.Tx, utxoView *U
|
||||
// number in accordance to BIP-68.
|
||||
// See: https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki
|
||||
// * (Compatibility)
|
||||
func LockTimeToSequence(isSeconds bool, locktime uint32) uint32 {
|
||||
func LockTimeToSequence(isSeconds bool, locktime uint64) uint64 {
|
||||
// If we're expressing the relative lock time in blocks, then the
|
||||
// corresponding sequence number is simply the desired input age.
|
||||
if !isSeconds {
|
||||
|
@ -82,10 +82,10 @@ func TestHaveBlock(t *testing.T) {
|
||||
{hash: dagconfig.MainNetParams.GenesisHash.String(), want: true},
|
||||
|
||||
// Block 3b should be present (as a second child of Block 2).
|
||||
{hash: "000000c7576990a9a73785181a36c0b346d0750c385345252c1cfa6951928c26", want: true},
|
||||
{hash: "00000033119c0f74eff8b4711fce3769ea33e8a69670d9c0366179a9a5b8aec3", want: true},
|
||||
|
||||
// Block 100000 should be present (as an orphan).
|
||||
{hash: "000000826ababf6b615336e6e1a5b479f4d2e580448cc090fc111b749a28654b", want: true},
|
||||
{hash: "000000824dca82828b9a18ac09ed7c93292f6a042fae580c1192c8cd086fd990", want: true},
|
||||
|
||||
// Random hashes should not be available.
|
||||
{hash: "123", want: false},
|
||||
|
@ -453,7 +453,7 @@ func dbPutSpendJournalEntry(dbTx database.Tx, blockHash *daghash.Hash, stxos []s
|
||||
//
|
||||
// Example 1:
|
||||
// From tx in main blockchain:
|
||||
// Blk 1, 0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098:0
|
||||
// Blk 1, b7c3332bc138e2c9429818f5fed500bcc1746544218772389054dc8047d7cd3f:0
|
||||
//
|
||||
// 03320496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52
|
||||
// <><------------------------------------------------------------------>
|
||||
|
@ -7,6 +7,7 @@ package blockdag
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"math"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
@ -235,7 +236,7 @@ func TestSpendJournalSerialization(t *testing.T) {
|
||||
Index: 0,
|
||||
},
|
||||
SignatureScript: hexToBytes("47304402204e45e16932b8af514961a1d3a1a25fdf3f4f7732e9d624c6c61548ab5fb8cd410220181522ec8eca07de4860a4acdd12909d831cc56cbbac4622082221a8768d1d0901"),
|
||||
Sequence: 0xffffffff,
|
||||
Sequence: math.MaxUint64,
|
||||
}},
|
||||
TxOut: []*wire.TxOut{{
|
||||
Value: 1000000000,
|
||||
@ -270,7 +271,7 @@ func TestSpendJournalSerialization(t *testing.T) {
|
||||
Index: 1,
|
||||
},
|
||||
SignatureScript: hexToBytes("493046022100c167eead9840da4a033c9a56470d7794a9bb1605b377ebe5688499b39f94be59022100fb6345cab4324f9ea0b9ee9169337534834638d818129778370f7d378ee4a325014104d962cac5390f12ddb7539507065d0def320d68c040f2e73337c3a1aaaab7195cb5c4d02e0959624d534f3c10c3cf3d73ca5065ebd62ae986b04c6d090d32627c"),
|
||||
Sequence: 0xffffffff,
|
||||
Sequence: math.MaxUint64,
|
||||
}},
|
||||
TxOut: []*wire.TxOut{{
|
||||
Value: 5000000,
|
||||
@ -288,7 +289,7 @@ func TestSpendJournalSerialization(t *testing.T) {
|
||||
Index: 0,
|
||||
},
|
||||
SignatureScript: hexToBytes("483045022100e256743154c097465cf13e89955e1c9ff2e55c46051b627751dee0144183157e02201d8d4f02cde8496aae66768f94d35ce54465bd4ae8836004992d3216a93a13f00141049d23ce8686fe9b802a7a938e8952174d35dd2c2089d4112001ed8089023ab4f93a3c9fcd5bfeaa9727858bf640dc1b1c05ec3b434bb59837f8640e8810e87742"),
|
||||
Sequence: 0xffffffff,
|
||||
Sequence: math.MaxUint64,
|
||||
}},
|
||||
TxOut: []*wire.TxOut{{
|
||||
Value: 5000000,
|
||||
@ -355,7 +356,7 @@ func TestSpendJournalErrors(t *testing.T) {
|
||||
Index: 0,
|
||||
},
|
||||
SignatureScript: hexToBytes("47304402204e45e16932b8af514961a1d3a1a25fdf3f4f7732e9d624c6c61548ab5fb8cd410220181522ec8eca07de4860a4acdd12909d831cc56cbbac4622082221a8768d1d0901"),
|
||||
Sequence: 0xffffffff,
|
||||
Sequence: math.MaxUint64,
|
||||
}},
|
||||
LockTime: 0,
|
||||
}},
|
||||
@ -372,7 +373,7 @@ func TestSpendJournalErrors(t *testing.T) {
|
||||
Index: 0,
|
||||
},
|
||||
SignatureScript: hexToBytes("47304402204e45e16932b8af514961a1d3a1a25fdf3f4f7732e9d624c6c61548ab5fb8cd410220181522ec8eca07de4860a4acdd12909d831cc56cbbac4622082221a8768d1d0901"),
|
||||
Sequence: 0xffffffff,
|
||||
Sequence: math.MaxUint64,
|
||||
}},
|
||||
LockTime: 0,
|
||||
}},
|
||||
@ -412,7 +413,7 @@ func TestUtxoSerialization(t *testing.T) {
|
||||
serialized []byte
|
||||
}{
|
||||
// From tx in main blockchain:
|
||||
// 0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098:0
|
||||
// b7c3332bc138e2c9429818f5fed500bcc1746544218772389054dc8047d7cd3f:0
|
||||
{
|
||||
name: "height 1, coinbase",
|
||||
entry: &UtxoEntry{
|
||||
@ -424,7 +425,7 @@ func TestUtxoSerialization(t *testing.T) {
|
||||
serialized: hexToBytes("03320496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52"),
|
||||
},
|
||||
// From tx in main blockchain:
|
||||
// 0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098:0
|
||||
// b7c3332bc138e2c9429818f5fed500bcc1746544218772389054dc8047d7cd3f:0
|
||||
{
|
||||
name: "height 1, coinbase, spent",
|
||||
entry: &UtxoEntry{
|
||||
|
@ -68,7 +68,7 @@ func ExampleBlockChain_ProcessBlock() {
|
||||
fmt.Printf("Block accepted. Is it an orphan?: %v", isOrphan)
|
||||
|
||||
// Output:
|
||||
// Failed to process block: already have block 000000094f48b026266f5b53d42ec33f453c48a31d036b785b743788e6bddc82
|
||||
// Failed to process block: already have block 2f0484f539fb39c0788abdea0805f799364c68cd162935504b80f3696fa99332
|
||||
}
|
||||
|
||||
// This example demonstrates how to convert the compact "bits" in a block header
|
||||
|
@ -6,6 +6,7 @@ package fullblocktests
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"math"
|
||||
"math/big"
|
||||
"time"
|
||||
|
||||
@ -71,7 +72,7 @@ var (
|
||||
"32303039204368616e63656c6c6f72206f" +
|
||||
"6e206272696e6b206f66207365636f6e64" +
|
||||
"206261696c6f757420666f72206261686b73"),
|
||||
Sequence: 0xffffffff,
|
||||
Sequence: math.MaxUint64,
|
||||
}},
|
||||
TxOut: []*wire.TxOut{{
|
||||
Value: 0,
|
||||
|
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.
@ -267,7 +267,7 @@ func determineMainChainBlocks(blocksMap map[daghash.Hash]*blockChainContext, tip
|
||||
//
|
||||
// Example 1:
|
||||
// From tx in main blockchain:
|
||||
// Blk 1, 0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098
|
||||
// Blk 1, b7c3332bc138e2c9429818f5fed500bcc1746544218772389054dc8047d7cd3f
|
||||
//
|
||||
// 010103320496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52
|
||||
// <><><><------------------------------------------------------------------>
|
||||
|
@ -18,7 +18,7 @@ func TestDeserializeUtxoEntryV0(t *testing.T) {
|
||||
serialized []byte
|
||||
}{
|
||||
// From tx in main blockchain:
|
||||
// 0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098
|
||||
// b7c3332bc138e2c9429818f5fed500bcc1746544218772389054dc8047d7cd3f
|
||||
{
|
||||
name: "Only output 0, coinbase",
|
||||
entries: map[uint32]*UtxoEntry{
|
||||
|
@ -167,7 +167,7 @@ func IsFinalizedTransaction(tx *btcutil.Tx, blockHeight int32, blockTime time.Ti
|
||||
// the transaction might still be finalized if the sequence number
|
||||
// for all transaction inputs is maxed out.
|
||||
for _, txIn := range msgTx.TxIn {
|
||||
if txIn.Sequence != math.MaxUint32 {
|
||||
if txIn.Sequence != math.MaxUint64 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
@ -238,26 +238,26 @@ var Block100000 = wire.MsgBlock{
|
||||
NumPrevBlocks: 2,
|
||||
PrevBlocks: []daghash.Hash{
|
||||
[32]byte{ // Make go vet happy.
|
||||
0x82, 0xdc, 0xbd, 0xe6, 0x88, 0x37, 0x74, 0x5b,
|
||||
0x78, 0x6b, 0x03, 0x1d, 0xa3, 0x48, 0x3c, 0x45,
|
||||
0x3f, 0xc3, 0x2e, 0xd4, 0x53, 0x5b, 0x6f, 0x26,
|
||||
0x26, 0xb0, 0x48, 0x4f, 0x09, 0x00, 0x00, 0x00,
|
||||
0x0f, 0xea, 0x33, 0x21, 0x67, 0xd0, 0x25, 0x05,
|
||||
0x89, 0x83, 0x19, 0x9f, 0x47, 0x50, 0x3a, 0x3b,
|
||||
0x91, 0xd2, 0x0a, 0xec, 0x57, 0x7a, 0x10, 0x89,
|
||||
0xd6, 0x36, 0xf8, 0x6d, 0x29, 0x00, 0x00, 0x00,
|
||||
}, // MainNet genesis
|
||||
[32]byte{ // Make go vet happy.
|
||||
0xc1, 0x5b, 0x71, 0xfe, 0x20, 0x70, 0x0f, 0xd0,
|
||||
0x08, 0x49, 0x88, 0x1b, 0x32, 0xb5, 0xbd, 0x13,
|
||||
0x17, 0xbe, 0x75, 0xe7, 0x29, 0x46, 0xdd, 0x03,
|
||||
0x01, 0x92, 0x90, 0xf1, 0xca, 0x8a, 0x88, 0x11,
|
||||
0x42, 0xeb, 0x66, 0x1f, 0x71, 0xb2, 0xb9, 0x26,
|
||||
0x05, 0xae, 0xe7, 0xf4, 0x8a, 0x6b, 0x7c, 0x86,
|
||||
0x33, 0x54, 0x0a, 0x27, 0xe5, 0x47, 0xb9, 0xb5,
|
||||
0xee, 0x13, 0x18, 0x83, 0x46, 0x00, 0x00, 0x00,
|
||||
}}, // SimNet genesis
|
||||
MerkleRoot: daghash.Hash([32]byte{ // Make go vet happy.
|
||||
0x66, 0x57, 0xa9, 0x25, 0x2a, 0xac, 0xd5, 0xc0,
|
||||
0xb2, 0x94, 0x09, 0x96, 0xec, 0xff, 0x95, 0x22,
|
||||
0x28, 0xc3, 0x06, 0x7c, 0xc3, 0x8d, 0x48, 0x85,
|
||||
0xef, 0xb5, 0xa4, 0xac, 0x42, 0x47, 0xe9, 0xf3,
|
||||
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(1529483563, 0), // 2018-06-20 08:32:43 +0000 UTC
|
||||
Timestamp: time.Unix(0x5b50aa0e, 0), // 2018-07-19 15:11:10 +0000 UTC
|
||||
Bits: 0x1e00ffff, // 503382015
|
||||
Nonce: 0x000ae53f, // 714047
|
||||
Nonce: 0x800c2a77, // 2148280951
|
||||
},
|
||||
Transactions: []*wire.MsgTx{
|
||||
{
|
||||
@ -271,7 +271,7 @@ var Block100000 = wire.MsgBlock{
|
||||
SignatureScript: []byte{
|
||||
0x04, 0x4c, 0x86, 0x04, 0x1b, 0x02, 0x06, 0x02,
|
||||
},
|
||||
Sequence: 0xffffffff,
|
||||
Sequence: math.MaxUint64,
|
||||
},
|
||||
},
|
||||
TxOut: []*wire.TxOut{
|
||||
@ -330,7 +330,7 @@ var Block100000 = wire.MsgBlock{
|
||||
0xc6, 0xf8, 0xa6, 0x30, 0x12, 0x1d, 0xf2, 0xb3,
|
||||
0xd3, // 65-byte pubkey
|
||||
},
|
||||
Sequence: 0xffffffff,
|
||||
Sequence: math.MaxUint64,
|
||||
},
|
||||
},
|
||||
TxOut: []*wire.TxOut{
|
||||
@ -398,7 +398,7 @@ var Block100000 = wire.MsgBlock{
|
||||
0x60, 0x63, 0x9d, 0xb4, 0x62, 0xe9, 0xcb, 0x85,
|
||||
0x0f, // 65-byte pubkey
|
||||
},
|
||||
Sequence: 0xffffffff,
|
||||
Sequence: math.MaxUint64,
|
||||
},
|
||||
},
|
||||
TxOut: []*wire.TxOut{
|
||||
@ -467,7 +467,7 @@ var Block100000 = wire.MsgBlock{
|
||||
0x6a, 0xf4, 0xcf, 0xaa, 0xea, 0x4e, 0xa1, 0x4f,
|
||||
0xbb, // 65-byte pubkey
|
||||
},
|
||||
Sequence: 0xffffffff,
|
||||
Sequence: math.MaxUint64,
|
||||
},
|
||||
},
|
||||
TxOut: []*wire.TxOut{
|
||||
|
@ -57,7 +57,7 @@ type TransactionInput struct {
|
||||
type CreateRawTransactionCmd struct {
|
||||
Inputs []TransactionInput
|
||||
Amounts map[string]float64 `jsonrpcusage:"{\"address\":amount,...}"` // In BTC
|
||||
LockTime *int64
|
||||
LockTime *uint64
|
||||
}
|
||||
|
||||
// NewCreateRawTransactionCmd returns a new instance which can be used to issue
|
||||
@ -65,7 +65,7 @@ type CreateRawTransactionCmd struct {
|
||||
//
|
||||
// Amounts are in BTC.
|
||||
func NewCreateRawTransactionCmd(inputs []TransactionInput, amounts map[string]float64,
|
||||
lockTime *int64) *CreateRawTransactionCmd {
|
||||
lockTime *uint64) *CreateRawTransactionCmd {
|
||||
|
||||
return &CreateRawTransactionCmd{
|
||||
Inputs: inputs,
|
||||
|
@ -71,13 +71,13 @@ func TestDAGSvrCmds(t *testing.T) {
|
||||
{Txid: "123", Vout: 1},
|
||||
}
|
||||
amounts := map[string]float64{"456": .0123}
|
||||
return btcjson.NewCreateRawTransactionCmd(txInputs, amounts, btcjson.Int64(12312333333))
|
||||
return btcjson.NewCreateRawTransactionCmd(txInputs, amounts, btcjson.Uint64(12312333333))
|
||||
},
|
||||
marshalled: `{"jsonrpc":"1.0","method":"createrawtransaction","params":[[{"txid":"123","vout":1}],{"456":0.0123},12312333333],"id":1}`,
|
||||
unmarshalled: &btcjson.CreateRawTransactionCmd{
|
||||
Inputs: []btcjson.TransactionInput{{Txid: "123", Vout: 1}},
|
||||
Amounts: map[string]float64{"456": .0123},
|
||||
LockTime: btcjson.Int64(12312333333),
|
||||
LockTime: btcjson.Uint64(12312333333),
|
||||
},
|
||||
},
|
||||
|
||||
|
@ -307,7 +307,7 @@ type Vin struct {
|
||||
Txid string `json:"txid"`
|
||||
Vout uint32 `json:"vout"`
|
||||
ScriptSig *ScriptSig `json:"scriptSig"`
|
||||
Sequence uint32 `json:"sequence"`
|
||||
Sequence uint64 `json:"sequence"`
|
||||
}
|
||||
|
||||
// IsCoinBase returns a bool to show if a Vin is a Coinbase one or not.
|
||||
@ -320,7 +320,7 @@ func (v *Vin) MarshalJSON() ([]byte, error) {
|
||||
if v.IsCoinBase() {
|
||||
coinbaseStruct := struct {
|
||||
Coinbase string `json:"coinbase"`
|
||||
Sequence uint32 `json:"sequence"`
|
||||
Sequence uint64 `json:"sequence"`
|
||||
}{
|
||||
Coinbase: v.Coinbase,
|
||||
Sequence: v.Sequence,
|
||||
@ -332,7 +332,7 @@ func (v *Vin) MarshalJSON() ([]byte, error) {
|
||||
Txid string `json:"txid"`
|
||||
Vout uint32 `json:"vout"`
|
||||
ScriptSig *ScriptSig `json:"scriptSig"`
|
||||
Sequence uint32 `json:"sequence"`
|
||||
Sequence uint64 `json:"sequence"`
|
||||
}{
|
||||
Txid: v.Txid,
|
||||
Vout: v.Vout,
|
||||
@ -355,7 +355,7 @@ type VinPrevOut struct {
|
||||
Vout uint32 `json:"vout"`
|
||||
ScriptSig *ScriptSig `json:"scriptSig"`
|
||||
PrevOut *PrevOut `json:"prevOut"`
|
||||
Sequence uint32 `json:"sequence"`
|
||||
Sequence uint64 `json:"sequence"`
|
||||
}
|
||||
|
||||
// IsCoinBase returns a bool to show if a Vin is a Coinbase one or not.
|
||||
@ -368,7 +368,7 @@ func (v *VinPrevOut) MarshalJSON() ([]byte, error) {
|
||||
if v.IsCoinBase() {
|
||||
coinbaseStruct := struct {
|
||||
Coinbase string `json:"coinbase"`
|
||||
Sequence uint32 `json:"sequence"`
|
||||
Sequence uint64 `json:"sequence"`
|
||||
}{
|
||||
Coinbase: v.Coinbase,
|
||||
Sequence: v.Sequence,
|
||||
@ -381,7 +381,7 @@ func (v *VinPrevOut) MarshalJSON() ([]byte, error) {
|
||||
Vout uint32 `json:"vout"`
|
||||
ScriptSig *ScriptSig `json:"scriptSig"`
|
||||
PrevOut *PrevOut `json:"prevOut,omitempty"`
|
||||
Sequence uint32 `json:"sequence"`
|
||||
Sequence uint64 `json:"sequence"`
|
||||
}{
|
||||
Txid: v.Txid,
|
||||
Vout: v.Vout,
|
||||
@ -444,13 +444,13 @@ type TxRawResult struct {
|
||||
Hash string `json:"hash,omitempty"`
|
||||
Size int32 `json:"size,omitempty"`
|
||||
Version int32 `json:"version"`
|
||||
LockTime uint32 `json:"locktime"`
|
||||
LockTime uint64 `json:"locktime"`
|
||||
Vin []Vin `json:"vin"`
|
||||
Vout []Vout `json:"vout"`
|
||||
BlockHash string `json:"blockhash,omitempty"`
|
||||
Confirmations uint64 `json:"confirmations,omitempty"`
|
||||
Time int64 `json:"time,omitempty"`
|
||||
Blocktime int64 `json:"blocktime,omitempty"`
|
||||
Time uint64 `json:"time,omitempty"`
|
||||
Blocktime uint64 `json:"blocktime,omitempty"`
|
||||
}
|
||||
|
||||
// SearchRawTransactionsResult models the data from the searchrawtransaction
|
||||
@ -461,20 +461,20 @@ type SearchRawTransactionsResult struct {
|
||||
Hash string `json:"hash"`
|
||||
Size string `json:"size"`
|
||||
Version int32 `json:"version"`
|
||||
LockTime uint32 `json:"locktime"`
|
||||
LockTime uint64 `json:"locktime"`
|
||||
Vin []VinPrevOut `json:"vin"`
|
||||
Vout []Vout `json:"vout"`
|
||||
BlockHash string `json:"blockhash,omitempty"`
|
||||
Confirmations uint64 `json:"confirmations,omitempty"`
|
||||
Time int64 `json:"time,omitempty"`
|
||||
Blocktime int64 `json:"blocktime,omitempty"`
|
||||
Time uint64 `json:"time,omitempty"`
|
||||
Blocktime uint64 `json:"blocktime,omitempty"`
|
||||
}
|
||||
|
||||
// TxRawDecodeResult models the data from the decoderawtransaction command.
|
||||
type TxRawDecodeResult struct {
|
||||
Txid string `json:"txid"`
|
||||
Version int32 `json:"version"`
|
||||
Locktime uint32 `json:"locktime"`
|
||||
Locktime uint64 `json:"locktime"`
|
||||
Vin []Vin `json:"vin"`
|
||||
Vout []Vout `json:"vout"`
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ type GetTransactionResult struct {
|
||||
Confirmations int64 `json:"confirmations"`
|
||||
BlockHash string `json:"blockhash"`
|
||||
BlockIndex int64 `json:"blockindex"`
|
||||
BlockTime int64 `json:"blocktime"`
|
||||
BlockTime uint64 `json:"blocktime"`
|
||||
TxID string `json:"txid"`
|
||||
WalletConflicts []string `json:"walletconflicts"`
|
||||
Time int64 `json:"time"`
|
||||
@ -65,7 +65,7 @@ type ListTransactionsResult struct {
|
||||
BIP125Replaceable string `json:"bip125-replaceable,omitempty"`
|
||||
BlockHash string `json:"blockhash,omitempty"`
|
||||
BlockIndex *int64 `json:"blockindex,omitempty"`
|
||||
BlockTime int64 `json:"blocktime,omitempty"`
|
||||
BlockTime uint64 `json:"blocktime,omitempty"`
|
||||
Category string `json:"category"`
|
||||
Confirmations int64 `json:"confirmations"`
|
||||
Fee *float64 `json:"fee,omitempty"`
|
||||
@ -125,7 +125,7 @@ type SignRawTransactionError struct {
|
||||
TxID string `json:"txid"`
|
||||
Vout uint32 `json:"vout"`
|
||||
ScriptSig string `json:"scriptSig"`
|
||||
Sequence uint32 `json:"sequence"`
|
||||
Sequence uint64 `json:"sequence"`
|
||||
Error string `json:"error"`
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
package dagconfig
|
||||
|
||||
import (
|
||||
"math"
|
||||
"time"
|
||||
|
||||
"github.com/daglabs/btcd/dagconfig/daghash"
|
||||
@ -31,9 +32,9 @@ var genesisCoinbaseTx = wire.MsgTx{
|
||||
0x6b, 0x20, 0x6f, 0x66, 0x20, 0x73, 0x65, 0x63, /* |k of sec|*/
|
||||
0x6f, 0x6e, 0x64, 0x20, 0x62, 0x61, 0x69, 0x6c, /* |ond bail| */
|
||||
0x6f, 0x75, 0x74, 0x20, 0x66, 0x6f, 0x72, 0x20, /* |out for |*/
|
||||
0x62, 0x61, 0x6e, 0x6b, 0x73, /* |banks| */
|
||||
0x62, 0x61, 0x6e, 0x6b, 0x73, /* |banks| */
|
||||
},
|
||||
Sequence: 0xffffffff,
|
||||
Sequence: math.MaxUint64,
|
||||
},
|
||||
},
|
||||
TxOut: []*wire.TxOut{
|
||||
@ -48,7 +49,7 @@ var genesisCoinbaseTx = wire.MsgTx{
|
||||
0x38, 0xc4, 0xf3, 0x55, 0x04, 0xe5, 0x1e, 0xc1, /* |8..U....| */
|
||||
0x12, 0xde, 0x5c, 0x38, 0x4d, 0xf7, 0xba, 0x0b, /* |..\8M...| */
|
||||
0x8d, 0x57, 0x8a, 0x4c, 0x70, 0x2b, 0x6b, 0xf1, /* |.W.Lp+k.| */
|
||||
0x1d, 0x5f, 0xac, /* |._.| */
|
||||
0x1d, 0x5f, 0xac, /* |._.| */
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -58,19 +59,19 @@ var genesisCoinbaseTx = wire.MsgTx{
|
||||
// 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.
|
||||
0x82, 0xdc, 0xbd, 0xe6, 0x88, 0x37, 0x74, 0x5b,
|
||||
0x78, 0x6b, 0x03, 0x1d, 0xa3, 0x48, 0x3c, 0x45,
|
||||
0x3f, 0xc3, 0x2e, 0xd4, 0x53, 0x5b, 0x6f, 0x26,
|
||||
0x26, 0xb0, 0x48, 0x4f, 0x09, 0x00, 0x00, 0x00,
|
||||
0x32, 0x93, 0xa9, 0x6f, 0x69, 0xf3, 0x80, 0x4b,
|
||||
0x50, 0x35, 0x29, 0x16, 0xcd, 0x68, 0x4c, 0x36,
|
||||
0x99, 0xf7, 0x05, 0x08, 0xea, 0xbd, 0x8a, 0x78,
|
||||
0xc0, 0x39, 0xfb, 0x39, 0xf5, 0x84, 0x04, 0x2f,
|
||||
})
|
||||
|
||||
// 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.
|
||||
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,
|
||||
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,
|
||||
})
|
||||
|
||||
// genesisBlock defines the genesis block of the block chain which serves as the
|
||||
@ -83,7 +84,7 @@ var genesisBlock = wire.MsgBlock{
|
||||
MerkleRoot: genesisMerkleRoot, // 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b
|
||||
Timestamp: time.Unix(0x5b28c4c8, 0), // 2018-06-19 08:54:32 +0000 UTC
|
||||
Bits: 0x1e00ffff, // 503382015 [000000ffff000000000000000000000000000000000000000000000000000000]
|
||||
Nonce: 0xc0192550, // 2148484547
|
||||
Nonce: 0x400a4c8f, // 1074416783
|
||||
},
|
||||
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.
|
||||
0x7c, 0x03, 0x27, 0x80, 0x78, 0xfc, 0xe8, 0xed,
|
||||
0xcd, 0xfc, 0x3d, 0xe1, 0x63, 0x45, 0x4c, 0x03,
|
||||
0x0f, 0xef, 0x38, 0x16, 0xec, 0x54, 0x61, 0x6f,
|
||||
0xca, 0xc9, 0x58, 0x12, 0xb4, 0x6a, 0x15, 0x08,
|
||||
0xeb, 0x98, 0xea, 0xaf, 0xf3, 0xf4, 0x7b, 0x3f,
|
||||
0x4b, 0x61, 0x57, 0xf8, 0x75, 0xfb, 0xc6, 0x9f,
|
||||
0xde, 0x88, 0x68, 0xbe, 0x5d, 0xc8, 0xab, 0xc6,
|
||||
0xb4, 0x1f, 0x85, 0xd8, 0x77, 0x03, 0xbf, 0x0f,
|
||||
})
|
||||
|
||||
// regTestGenesisMerkleRoot is the hash of the first transaction in the genesis
|
||||
@ -112,7 +113,7 @@ var regTestGenesisBlock = wire.MsgBlock{
|
||||
MerkleRoot: regTestGenesisMerkleRoot, // 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b
|
||||
Timestamp: time.Unix(0x5b28c636, 0), // 2018-06-19 09:00:38 +0000 UTC
|
||||
Bits: 0x207fffff, // 545259519 [7fffff0000000000000000000000000000000000000000000000000000000000]
|
||||
Nonce: 1,
|
||||
Nonce: 0xdffffff9,
|
||||
},
|
||||
Transactions: []*wire.MsgTx{&genesisCoinbaseTx},
|
||||
}
|
||||
@ -120,10 +121,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.
|
||||
0x91, 0x1c, 0xe0, 0x47, 0x77, 0xad, 0x5e, 0xc5,
|
||||
0x60, 0x10, 0x21, 0x32, 0x51, 0x1b, 0x39, 0x06,
|
||||
0x24, 0xb3, 0xbf, 0x08, 0x8e, 0x04, 0x8c, 0xd3,
|
||||
0x80, 0xb4, 0x83, 0x83, 0xed, 0x00, 0x00, 0x00,
|
||||
0x25, 0x62, 0xec, 0x05, 0x42, 0x4b, 0x74, 0x37,
|
||||
0x5a, 0x67, 0xd2, 0x6e, 0x24, 0x6c, 0xe8, 0x96,
|
||||
0xdf, 0xd6, 0x71, 0x88, 0xc8, 0xbb, 0x89, 0xd6,
|
||||
0xd9, 0x23, 0x84, 0x2b, 0xd0, 0x69, 0x39, 0xe7,
|
||||
})
|
||||
|
||||
// testNet3GenesisMerkleRoot is the hash of the first transaction in the genesis
|
||||
@ -149,10 +150,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.
|
||||
0xc1, 0x5b, 0x71, 0xfe, 0x20, 0x70, 0x0f, 0xd0,
|
||||
0x08, 0x49, 0x88, 0x1b, 0x32, 0xb5, 0xbd, 0x13,
|
||||
0x17, 0xbe, 0x75, 0xe7, 0x29, 0x46, 0xdd, 0x03,
|
||||
0x01, 0x92, 0x90, 0xf1, 0xca, 0x8a, 0x88, 0x11,
|
||||
0x93, 0x0f, 0x30, 0xd1, 0x0b, 0xaf, 0x9d, 0x5b,
|
||||
0x58, 0xdc, 0xad, 0x78, 0xee, 0x16, 0xd0, 0x12,
|
||||
0x10, 0xac, 0x2c, 0xa3, 0x08, 0xc4, 0x83, 0x33,
|
||||
0x57, 0xb2, 0xaf, 0x5a, 0x22, 0xa2, 0xf9, 0x20,
|
||||
})
|
||||
|
||||
// simNetGenesisMerkleRoot is the hash of the first transaction in the genesis
|
||||
@ -168,9 +169,9 @@ var simNetGenesisBlock = wire.MsgBlock{
|
||||
NumPrevBlocks: 0,
|
||||
PrevBlocks: []daghash.Hash{},
|
||||
MerkleRoot: simNetGenesisMerkleRoot, // 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b
|
||||
Timestamp: time.Unix(0x5b28c7ec, 0), // 2018-06-19 09:07:56 +0000 UTC
|
||||
Timestamp: time.Unix(0x5b50a002, 0), // 2018-07-19 14:28:18 +0000 UTC
|
||||
Bits: 0x207fffff, // 545259519 [7fffff0000000000000000000000000000000000000000000000000000000000]
|
||||
Nonce: 0x9ffffffb, // 2684354555
|
||||
Nonce: 0x5ffffffd, // 1610612733
|
||||
},
|
||||
Transactions: []*wire.MsgTx{&genesisCoinbaseTx},
|
||||
}
|
||||
|
@ -121,147 +121,87 @@ 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, 0x3b, 0xa3, 0xed, /* |.....;..| */
|
||||
0xfd, 0x7a, 0x7b, 0x12, 0xb2, 0x7a, 0xc7, 0x2c, /* |.z{..z.,| */
|
||||
0x3e, 0x67, 0x76, 0x8f, 0x61, 0x7f, 0xc8, 0x1b, /* |>gv.a...| */
|
||||
0xc3, 0x88, 0x8a, 0x51, 0x32, 0x3a, 0x9f, 0xb8, /* |...Q2:..| */
|
||||
0xaa, 0x4b, 0x1e, 0x5e, 0x4a, 0xc8, 0xc4, 0x28, /* |.K.^J..(| */
|
||||
0x5b, 0xff, 0xff, 0x00, 0x1e, 0x50, 0x25, 0x19, /* |[....P%.| */
|
||||
0xc0, 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, 0x01, 0x00, 0xf2, /* |s.......| */
|
||||
0x05, 0x2a, 0x01, 0x00, 0x00, 0x00, 0x43, 0x41, /* |.*....CA| */
|
||||
0x04, 0x67, 0x8a, 0xfd, 0xb0, 0xfe, 0x55, 0x48, /* |.g....UH| */
|
||||
0x27, 0x19, 0x67, 0xf1, 0xa6, 0x71, 0x30, 0xb7, /* |'.g..q0.| */
|
||||
0x10, 0x5c, 0xd6, 0xa8, 0x28, 0xe0, 0x39, 0x09, /* |.\..(.9.| */
|
||||
0xa6, 0x79, 0x62, 0xe0, 0xea, 0x1f, 0x61, 0xde, /* |.yb...a.| */
|
||||
0xb6, 0x49, 0xf6, 0xbc, 0x3f, 0x4c, 0xef, 0x38, /* |.I..?L.8| */
|
||||
0xc4, 0xf3, 0x55, 0x04, 0xe5, 0x1e, 0xc1, 0x12, /* |..U.....| */
|
||||
0xde, 0x5c, 0x38, 0x4d, 0xf7, 0xba, 0x0b, 0x8d, /* |.\8M....| */
|
||||
0x57, 0x8a, 0x4c, 0x70, 0x2b, 0x6b, 0xf1, 0x1d, /* |W.Lp+k..| */
|
||||
0x5f, 0xac, 0x00, 0x00, 0x00, 0x00, /* |_.....| */
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 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, 0xc8, 0xc4, 0x28, 0x5b, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00,
|
||||
0x1e, 0x8f, 0x4c, 0x0a, 0x40, 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, 0x1d, 0x01, 0x04, 0x45, 0x54, 0x68, 0x65, 0x20, 0x54, 0x69, 0x6d, 0x65,
|
||||
0x73, 0x20, 0x30, 0x33, 0x2f, 0x4a, 0x61, 0x6e, 0x2f, 0x32, 0x30, 0x30, 0x39, 0x20, 0x43, 0x68,
|
||||
0x61, 0x6e, 0x63, 0x65, 0x6c, 0x6c, 0x6f, 0x72, 0x20, 0x6f, 0x6e, 0x20, 0x62, 0x72, 0x69, 0x6e,
|
||||
0x6b, 0x20, 0x6f, 0x66, 0x20, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x20, 0x62, 0x61, 0x69, 0x6c,
|
||||
0x6f, 0x75, 0x74, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x62, 0x61, 0x6e, 0x6b, 0x73, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0xf2, 0x05, 0x2a, 0x01, 0x00, 0x00, 0x00, 0x43, 0x41,
|
||||
0x04, 0x67, 0x8a, 0xfd, 0xb0, 0xfe, 0x55, 0x48, 0x27, 0x19, 0x67, 0xf1, 0xa6, 0x71, 0x30, 0xb7,
|
||||
0x10, 0x5c, 0xd6, 0xa8, 0x28, 0xe0, 0x39, 0x09, 0xa6, 0x79, 0x62, 0xe0, 0xea, 0x1f, 0x61, 0xde,
|
||||
0xb6, 0x49, 0xf6, 0xbc, 0x3f, 0x4c, 0xef, 0x38, 0xc4, 0xf3, 0x55, 0x04, 0xe5, 0x1e, 0xc1, 0x12,
|
||||
0xde, 0x5c, 0x38, 0x4d, 0xf7, 0xba, 0x0b, 0x8d, 0x57, 0x8a, 0x4c, 0x70, 0x2b, 0x6b, 0xf1, 0x1d,
|
||||
0x5f, 0xac, 0x00, 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, 0x3b, 0xa3, 0xed, /* |.....;..| */
|
||||
0xfd, 0x7a, 0x7b, 0x12, 0xb2, 0x7a, 0xc7, 0x2c, /* |.z{..z.,| */
|
||||
0x3e, 0x67, 0x76, 0x8f, 0x61, 0x7f, 0xc8, 0x1b, /* |>gv.a...| */
|
||||
0xc3, 0x88, 0x8a, 0x51, 0x32, 0x3a, 0x9f, 0xb8, /* |...Q2:..| */
|
||||
0xaa, 0x4b, 0x1e, 0x5e, 0x4a, 0x36, 0xc6, 0x28, /* |.K.^J6.(| */
|
||||
0x5b, 0xff, 0xff, 0x7f, 0x20, 0x01, 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, 0x01, 0x00, 0xf2, /* |s.......| */
|
||||
0x05, 0x2a, 0x01, 0x00, 0x00, 0x00, 0x43, 0x41, /* |.*....CA| */
|
||||
0x04, 0x67, 0x8a, 0xfd, 0xb0, 0xfe, 0x55, 0x48, /* |.g....UH| */
|
||||
0x27, 0x19, 0x67, 0xf1, 0xa6, 0x71, 0x30, 0xb7, /* |'.g..q0.| */
|
||||
0x10, 0x5c, 0xd6, 0xa8, 0x28, 0xe0, 0x39, 0x09, /* |.\..(.9.| */
|
||||
0xa6, 0x79, 0x62, 0xe0, 0xea, 0x1f, 0x61, 0xde, /* |.yb...a.| */
|
||||
0xb6, 0x49, 0xf6, 0xbc, 0x3f, 0x4c, 0xef, 0x38, /* |.I..?L.8| */
|
||||
0xc4, 0xf3, 0x55, 0x04, 0xe5, 0x1e, 0xc1, 0x12, /* |..U.....| */
|
||||
0xde, 0x5c, 0x38, 0x4d, 0xf7, 0xba, 0x0b, 0x8d, /* |.\8M....| */
|
||||
0x57, 0x8a, 0x4c, 0x70, 0x2b, 0x6b, 0xf1, 0x1d, /* |W.Lp+k..| */
|
||||
0x5f, 0xac, 0x00, 0x00, 0x00, 0x00, /* |_.....| */
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 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, 0x36, 0xc6, 0x28, 0x5b, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7f,
|
||||
0x20, 0xf9, 0xff, 0xff, 0xdf, 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, 0x1d, 0x01, 0x04, 0x45, 0x54, 0x68, 0x65, 0x20, 0x54, 0x69, 0x6d, 0x65,
|
||||
0x73, 0x20, 0x30, 0x33, 0x2f, 0x4a, 0x61, 0x6e, 0x2f, 0x32, 0x30, 0x30, 0x39, 0x20, 0x43, 0x68,
|
||||
0x61, 0x6e, 0x63, 0x65, 0x6c, 0x6c, 0x6f, 0x72, 0x20, 0x6f, 0x6e, 0x20, 0x62, 0x72, 0x69, 0x6e,
|
||||
0x6b, 0x20, 0x6f, 0x66, 0x20, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x20, 0x62, 0x61, 0x69, 0x6c,
|
||||
0x6f, 0x75, 0x74, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x62, 0x61, 0x6e, 0x6b, 0x73, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0xf2, 0x05, 0x2a, 0x01, 0x00, 0x00, 0x00, 0x43, 0x41,
|
||||
0x04, 0x67, 0x8a, 0xfd, 0xb0, 0xfe, 0x55, 0x48, 0x27, 0x19, 0x67, 0xf1, 0xa6, 0x71, 0x30, 0xb7,
|
||||
0x10, 0x5c, 0xd6, 0xa8, 0x28, 0xe0, 0x39, 0x09, 0xa6, 0x79, 0x62, 0xe0, 0xea, 0x1f, 0x61, 0xde,
|
||||
0xb6, 0x49, 0xf6, 0xbc, 0x3f, 0x4c, 0xef, 0x38, 0xc4, 0xf3, 0x55, 0x04, 0xe5, 0x1e, 0xc1, 0x12,
|
||||
0xde, 0x5c, 0x38, 0x4d, 0xf7, 0xba, 0x0b, 0x8d, 0x57, 0x8a, 0x4c, 0x70, 0x2b, 0x6b, 0xf1, 0x1d,
|
||||
0x5f, 0xac, 0x00, 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, 0x3b, 0xa3, 0xed, /* |.....;..| */
|
||||
0xfd, 0x7a, 0x7b, 0x12, 0xb2, 0x7a, 0xc7, 0x2c, /* |.z{..z.,| */
|
||||
0x3e, 0x67, 0x76, 0x8f, 0x61, 0x7f, 0xc8, 0x1b, /* |>gv.a...| */
|
||||
0xc3, 0x88, 0x8a, 0x51, 0x32, 0x3a, 0x9f, 0xb8, /* |...Q2:..| */
|
||||
0xaa, 0x4b, 0x1e, 0x5e, 0x4a, 0x06, 0xc7, 0x28, /* |.K.^J..(| */
|
||||
0x5b, 0xff, 0xff, 0x00, 0x1e, 0x3b, 0x1b, 0x2f, /* |[....;./| */
|
||||
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, 0x01, 0x00, 0xf2, /* |s.......| */
|
||||
0x05, 0x2a, 0x01, 0x00, 0x00, 0x00, 0x43, 0x41, /* |.*....CA| */
|
||||
0x04, 0x67, 0x8a, 0xfd, 0xb0, 0xfe, 0x55, 0x48, /* |.g....UH| */
|
||||
0x27, 0x19, 0x67, 0xf1, 0xa6, 0x71, 0x30, 0xb7, /* |'.g..q0.| */
|
||||
0x10, 0x5c, 0xd6, 0xa8, 0x28, 0xe0, 0x39, 0x09, /* |.\..(.9.| */
|
||||
0xa6, 0x79, 0x62, 0xe0, 0xea, 0x1f, 0x61, 0xde, /* |.yb...a.| */
|
||||
0xb6, 0x49, 0xf6, 0xbc, 0x3f, 0x4c, 0xef, 0x38, /* |.I..?L.8| */
|
||||
0xc4, 0xf3, 0x55, 0x04, 0xe5, 0x1e, 0xc1, 0x12, /* |..U.....| */
|
||||
0xde, 0x5c, 0x38, 0x4d, 0xf7, 0xba, 0x0b, 0x8d, /* |.\8M....| */
|
||||
0x57, 0x8a, 0x4c, 0x70, 0x2b, 0x6b, 0xf1, 0x1d, /* |W.Lp+k..| */
|
||||
0x5f, 0xac, 0x00, 0x00, 0x00, 0x00, /* |_.....| */
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 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, 0x06, 0xc7, 0x28, 0x5b, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00,
|
||||
0x1e, 0x3b, 0x1b, 0x2f, 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, 0x1d, 0x01, 0x04, 0x45, 0x54, 0x68, 0x65, 0x20, 0x54, 0x69, 0x6d, 0x65,
|
||||
0x73, 0x20, 0x30, 0x33, 0x2f, 0x4a, 0x61, 0x6e, 0x2f, 0x32, 0x30, 0x30, 0x39, 0x20, 0x43, 0x68,
|
||||
0x61, 0x6e, 0x63, 0x65, 0x6c, 0x6c, 0x6f, 0x72, 0x20, 0x6f, 0x6e, 0x20, 0x62, 0x72, 0x69, 0x6e,
|
||||
0x6b, 0x20, 0x6f, 0x66, 0x20, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x20, 0x62, 0x61, 0x69, 0x6c,
|
||||
0x6f, 0x75, 0x74, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x62, 0x61, 0x6e, 0x6b, 0x73, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0xf2, 0x05, 0x2a, 0x01, 0x00, 0x00, 0x00, 0x43, 0x41,
|
||||
0x04, 0x67, 0x8a, 0xfd, 0xb0, 0xfe, 0x55, 0x48, 0x27, 0x19, 0x67, 0xf1, 0xa6, 0x71, 0x30, 0xb7,
|
||||
0x10, 0x5c, 0xd6, 0xa8, 0x28, 0xe0, 0x39, 0x09, 0xa6, 0x79, 0x62, 0xe0, 0xea, 0x1f, 0x61, 0xde,
|
||||
0xb6, 0x49, 0xf6, 0xbc, 0x3f, 0x4c, 0xef, 0x38, 0xc4, 0xf3, 0x55, 0x04, 0xe5, 0x1e, 0xc1, 0x12,
|
||||
0xde, 0x5c, 0x38, 0x4d, 0xf7, 0xba, 0x0b, 0x8d, 0x57, 0x8a, 0x4c, 0x70, 0x2b, 0x6b, 0xf1, 0x1d,
|
||||
0x5f, 0xac, 0x00, 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, 0x3b, 0xa3, 0xed, /* |.....;..| */
|
||||
0xfd, 0x7a, 0x7b, 0x12, 0xb2, 0x7a, 0xc7, 0x2c, /* |.z{..z.,| */
|
||||
0x3e, 0x67, 0x76, 0x8f, 0x61, 0x7f, 0xc8, 0x1b, /* |>gv.a...| */
|
||||
0xc3, 0x88, 0x8a, 0x51, 0x32, 0x3a, 0x9f, 0xb8, /* |...Q2:..| */
|
||||
0xaa, 0x4b, 0x1e, 0x5e, 0x4a, 0xec, 0xc7, 0x28, /* |.K.^J..(| */
|
||||
0x5b, 0xff, 0xff, 0x7f, 0x20, 0xfb, 0xff, 0xff, /* |[... ...| */
|
||||
0x9f, 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, 0x01, 0x00, 0xf2, /* |s.......| */
|
||||
0x05, 0x2a, 0x01, 0x00, 0x00, 0x00, 0x43, 0x41, /* |.*....CA| */
|
||||
0x04, 0x67, 0x8a, 0xfd, 0xb0, 0xfe, 0x55, 0x48, /* |.g....UH| */
|
||||
0x27, 0x19, 0x67, 0xf1, 0xa6, 0x71, 0x30, 0xb7, /* |'.g..q0.| */
|
||||
0x10, 0x5c, 0xd6, 0xa8, 0x28, 0xe0, 0x39, 0x09, /* |.\..(.9.| */
|
||||
0xa6, 0x79, 0x62, 0xe0, 0xea, 0x1f, 0x61, 0xde, /* |.yb...a.| */
|
||||
0xb6, 0x49, 0xf6, 0xbc, 0x3f, 0x4c, 0xef, 0x38, /* |.I..?L.8| */
|
||||
0xc4, 0xf3, 0x55, 0x04, 0xe5, 0x1e, 0xc1, 0x12, /* |..U.....| */
|
||||
0xde, 0x5c, 0x38, 0x4d, 0xf7, 0xba, 0x0b, 0x8d, /* |.\8M....| */
|
||||
0x57, 0x8a, 0x4c, 0x70, 0x2b, 0x6b, 0xf1, 0x1d, /* |W.Lp+k..| */
|
||||
0x5f, 0xac, 0x00, 0x00, 0x00, 0x00, /* |_.....| */
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 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, 0x02, 0xa0, 0x50, 0x5b, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7f,
|
||||
0x20, 0xfd, 0xff, 0xff, 0x5f, 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, 0x1d, 0x01, 0x04, 0x45, 0x54, 0x68, 0x65, 0x20, 0x54, 0x69, 0x6d, 0x65,
|
||||
0x73, 0x20, 0x30, 0x33, 0x2f, 0x4a, 0x61, 0x6e, 0x2f, 0x32, 0x30, 0x30, 0x39, 0x20, 0x43, 0x68,
|
||||
0x61, 0x6e, 0x63, 0x65, 0x6c, 0x6c, 0x6f, 0x72, 0x20, 0x6f, 0x6e, 0x20, 0x62, 0x72, 0x69, 0x6e,
|
||||
0x6b, 0x20, 0x6f, 0x66, 0x20, 0x73, 0x65, 0x63, 0x6f, 0x6e, 0x64, 0x20, 0x62, 0x61, 0x69, 0x6c,
|
||||
0x6f, 0x75, 0x74, 0x20, 0x66, 0x6f, 0x72, 0x20, 0x62, 0x61, 0x6e, 0x6b, 0x73, 0xff, 0xff, 0xff,
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0x01, 0x00, 0xf2, 0x05, 0x2a, 0x01, 0x00, 0x00, 0x00, 0x43, 0x41,
|
||||
0x04, 0x67, 0x8a, 0xfd, 0xb0, 0xfe, 0x55, 0x48, 0x27, 0x19, 0x67, 0xf1, 0xa6, 0x71, 0x30, 0xb7,
|
||||
0x10, 0x5c, 0xd6, 0xa8, 0x28, 0xe0, 0x39, 0x09, 0xa6, 0x79, 0x62, 0xe0, 0xea, 0x1f, 0x61, 0xde,
|
||||
0xb6, 0x49, 0xf6, 0xbc, 0x3f, 0x4c, 0xef, 0x38, 0xc4, 0xf3, 0x55, 0x04, 0xe5, 0x1e, 0xc1, 0x12,
|
||||
0xde, 0x5c, 0x38, 0x4d, 0xf7, 0xba, 0x0b, 0x8d, 0x57, 0x8a, 0x4c, 0x70, 0x2b, 0x6b, 0xf1, 0x1d,
|
||||
0x5f, 0xac, 0x00, 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: 254 bytes
|
||||
// Serialized block size: 266 bytes
|
||||
}
|
||||
|
BIN
database/testdata/blocks1-256.bz2
vendored
BIN
database/testdata/blocks1-256.bz2
vendored
Binary file not shown.
@ -208,7 +208,7 @@ the method name for further details such as parameter and return information.
|
||||
| | |
|
||||
|---|---|
|
||||
|Method|createrawtransaction|
|
||||
|Parameters|1. transaction inputs (JSON array, required) - json array of json objects<br />`[`<br /> `{`<br /> `"txid": "hash", (string, required) the hash of the input transaction`<br /> `"vout": n (numeric, required) the specific output of the input transaction to redeem`<br /> `}, ...`<br />`]`<br />2. addresses and amounts (JSON object, required) - json object with addresses as keys and amounts as values<br />`{`<br /> `"address": n.nnn (numeric, required) the address to send to as the key and the amount in BTC as the value`<br /> `, ...`<br />`}`<br />3. locktime (int64, optional, default=0) - specifies the transaction locktime. If non-zero, the inputs will also have their locktimes activated. |
|
||||
|Parameters|1. transaction inputs (JSON array, required) - json array of json objects<br />`[`<br /> `{`<br /> `"txid": "hash", (string, required) the hash of the input transaction`<br /> `"vout": n (numeric, required) the specific output of the input transaction to redeem`<br /> `}, ...`<br />`]`<br />2. addresses and amounts (JSON object, required) - json object with addresses as keys and amounts as values<br />`{`<br /> `"address": n.nnn (numeric, required) the address to send to as the key and the amount in BTC as the value`<br /> `, ...`<br />`}`<br />3. locktime (uint64, optional, default=0) - specifies the transaction locktime. If non-zero, the inputs will also have their locktimes activated. |
|
||||
|Description|Returns a new transaction spending the provided inputs and sending to the provided addresses.<br />The transaction inputs are not signed in the created transaction.<br />The `signrawtransaction` RPC command provided by wallet must be used to sign the resulting transaction.|
|
||||
|Returns|`"transaction" (string) hex-encoded bytes of the serialized transaction`|
|
||||
|Example Parameters|1. transaction inputs `[{"txid":"e6da89de7a6b8508ce8f371a3d0535b04b5e108cb1a6e9284602d3bfd357c018","vout":1}]`<br />2. addresses and amounts `{"13cgrTP7wgbZYWrY9BZ22BV6p82QXQT3nY": 0.49213337}`<br />3. locktime `0`|
|
||||
@ -277,7 +277,7 @@ the method name for further details such as parameter and return information.
|
||||
|Returns (verbose=true, verbosetx=false)|`{ (json object)`<br /> `"hash": "blockhash", (string) the hash of the block (same as provided)`<br /> `"confirmations": n, (numeric) the number of confirmations`<br /> `"size", n (numeric) the size of the block`<br /> `"size": n, (numeric) the size of the block`<br /> `"height": n, (numeric) the height of the block in the block chain`<br /> `"version": n, (numeric) the block version`<br /> `"merkleroot": "hash", (string) root hash of the merkle tree`<br /> `"tx": [ (json array of string) the transaction hashes`<br /> `"transactionhash", (string) hash of the parent transaction`<br /> `...`<br /> `]`<br /> `"time": n, (numeric) the block time in seconds since 1 Jan 1970 GMT`<br /> `"nonce": n, (numeric) the block nonce`<br /> `"bits", n, (numeric) the bits which represent the block difficulty`<br /> `difficulty: n.nn, (numeric) the proof-of-work difficulty as a multiple of the minimum difficulty`<br /> `"previousblockhash": "hash", (string) the hash of the previous block`<br /> `"nextblockhash": "hash", (string) the hash of the next block (only if there is one)`<br />`}`|
|
||||
|Returns (verbose=true, verbosetx=true)|`{ (json object)`<br /> `"hash": "blockhash", (string) the hash of the block (same as provided)`<br /> `"confirmations": n, (numeric) the number of confirmations`<br /> `"size", n (numeric) the size of the block`<br /> `"size": n, (numeric) the size of the block`<br /> `"height": n, (numeric) the height of the block in the block chain`<br /> `"version": n, (numeric) the block version`<br /> `"merkleroot": "hash", (string) root hash of the merkle tree`<br /> `"rawtx": [ (array of json objects) the transactions as json objects`<br /> `(see getrawtransaction json object details)`<br /> `]`<br /> `"time": n, (numeric) the block time in seconds since 1 Jan 1970 GMT`<br /> `"nonce": n, (numeric) the block nonce`<br /> `"bits", n, (numeric) the bits which represent the block difficulty`<br /> `difficulty: n.nn, (numeric) the proof-of-work difficulty as a multiple of the minimum difficulty`<br /> `"previousblockhash": "hash", (string) the hash of the previous block`<br /> `"nextblockhash": "hash", (string) the hash of the next block`<br />`}`|
|
||||
|Example Return (verbose=false)|`"010000000000000000000000000000000000000000000000000000000000000000000000`<br />`3ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a29ab5f49`<br />`ffff001d1dac2b7c01010000000100000000000000000000000000000000000000000000`<br />`00000000000000000000ffffffff4d04ffff001d0104455468652054696d65732030332f`<br />`4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f`<br />`6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01000000434104`<br />`678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f`<br />`4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac00000000"`<br /><font color="orange">**Newlines added for display purposes. The actual return does not contain newlines.**</font>|
|
||||
|Example Return (verbose=true, verbosetx=false)|`{`<br /> `"hash": "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",`<br /> `"confirmations": 277113,`<br /> `"size": 285,`<br /> `"height": 0,`<br /> `"version": 1,`<br /> `"merkleroot": "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b",`<br /> `"tx": [`<br /> `"4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"`<br /> `],`<br /> `"time": 1231006505,`<br /> `"nonce": 2083236893,`<br /> `"bits": "1d00ffff",`<br /> `"difficulty": 1,`<br /> `"previousblockhash": "0000000000000000000000000000000000000000000000000000000000000000",`<br /> `"nextblockhash": "00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048"`<br />`}`|
|
||||
|Example Return (verbose=true, verbosetx=false)|`{`<br /> `"hash": "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",`<br /> `"confirmations": 277113,`<br /> `"size": 285,`<br /> `"height": 0,`<br /> `"version": 1,`<br /> `"merkleroot": "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b",`<br /> `"tx": [`<br /> `"4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"`<br /> `],`<br /> `"time": 1231006505,`<br /> `"nonce": 2083236893,`<br /> `"bits": "1d00ffff",`<br /> `"difficulty": 1,`<br /> `"previousblockhash": "0000000000000000000000000000000000000000000000000000000000000000",`<br /> `"nextblockhash": "ec85da8297525c2a2a5f3e826510ea1a48ee741e13a18b93ceeb2fb6c9848925,"`<br />`}`|
|
||||
[Return to Overview](#MethodOverview)<br />
|
||||
|
||||
***
|
||||
@ -1222,7 +1222,7 @@ Which results in:
|
||||
```bash
|
||||
Hash: 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
|
||||
Previous Block: 0000000000000000000000000000000000000000000000000000000000000000
|
||||
Next Block: 00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048
|
||||
Next Block: ec85da8297525c2a2a5f3e826510ea1a48ee741e13a18b93ceeb2fb6c9848925,
|
||||
Merkle root: 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b
|
||||
Timestamp: 2009-01-03 18:15:05 +0000 UTC
|
||||
Confirmations: 277290
|
||||
|
@ -144,7 +144,7 @@ func TestBIP0113(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("unable to query for chain info: %v", err)
|
||||
}
|
||||
tx.LockTime = uint32(chainInfo.MedianTime) + 1
|
||||
tx.LockTime = chainInfo.MedianTime + 1
|
||||
|
||||
sigScript, err := txscript.SignatureScript(tx, 0, testPkScript,
|
||||
txscript.SigHashAll, outputKey, true)
|
||||
@ -164,42 +164,6 @@ func TestBIP0113(t *testing.T) {
|
||||
"non-final, instead: %v", err)
|
||||
}
|
||||
|
||||
<<<<<<< HEAD:integration/csv_fork_test.go
|
||||
// However, since the block validation consensus rules haven't yet
|
||||
// activated, a block including the transaction should be accepted.
|
||||
txns := []*btcutil.Tx{btcutil.NewTx(tx)}
|
||||
block, err := r.GenerateAndSubmitBlock(txns, -1, time.Time{})
|
||||
if err != nil {
|
||||
t.Fatalf("unable to submit block: %v", err)
|
||||
}
|
||||
txid := tx.TxHash()
|
||||
assertTxInBlock(r, t, block.Hash(), &txid)
|
||||
|
||||
// At this point, the block height should be 103: we mined 101 blocks
|
||||
// to create a single mature output, then an additional block to create
|
||||
// a new output, and then mined a single block above to include our
|
||||
// transaction.
|
||||
assertChainHeight(r, t, 103)
|
||||
|
||||
// Next, mine enough blocks to ensure that the soft-fork becomes
|
||||
// activated. Assert that the block version of the second-to-last block
|
||||
// in the final range is active.
|
||||
|
||||
// Next, mine ensure blocks to ensure that the soft-fork becomes
|
||||
// active. We're at height 103 and we need 200 blocks to be mined after
|
||||
// the genesis target period, so we mine 196 blocks. This'll put us at
|
||||
// height 299. The getblockchaininfo call checks the state for the
|
||||
// block AFTER the current height.
|
||||
numBlocks := (r.ActiveNet.MinerConfirmationWindow * 2) - 4
|
||||
if _, err := r.Node.Generate(numBlocks); err != nil {
|
||||
t.Fatalf("unable to generate blocks: %v", err)
|
||||
}
|
||||
|
||||
assertChainHeight(r, t, 299)
|
||||
assertSoftForkStatus(r, t, csvKey, blockdag.ThresholdActive)
|
||||
|
||||
=======
|
||||
>>>>>>> origin/master:integration/csv_test.go
|
||||
// The timeLockDeltas slice represents a series of deviations from the
|
||||
// current MTP which will be used to test border conditions w.r.t
|
||||
// transaction finality. -1 indicates 1 second prior to the MTP, 0
|
||||
@ -235,7 +199,7 @@ func TestBIP0113(t *testing.T) {
|
||||
PkScript: addrScript,
|
||||
Value: outputValue - 1000,
|
||||
})
|
||||
tx.LockTime = uint32(medianTimePast + timeLockDelta)
|
||||
tx.LockTime = medianTimePast + timeLockDelta
|
||||
sigScript, err = txscript.SignatureScript(tx, 0, testPkScript,
|
||||
txscript.SigHashAll, outputKey, true)
|
||||
if err != nil {
|
||||
@ -273,15 +237,15 @@ func TestBIP0113(t *testing.T) {
|
||||
// createCSVOutput creates an output paying to a trivially redeemable CSV
|
||||
// pkScript with the specified time-lock.
|
||||
func createCSVOutput(r *rpctest.Harness, t *testing.T,
|
||||
numSatoshis btcutil.Amount, timeLock int32,
|
||||
numSatoshis btcutil.Amount, timeLock int64,
|
||||
isSeconds bool) ([]byte, *wire.OutPoint, *wire.MsgTx, error) {
|
||||
|
||||
// Convert the time-lock to the proper sequence lock based according to
|
||||
// if the lock is seconds or time based.
|
||||
sequenceLock := blockdag.LockTimeToSequence(isSeconds,
|
||||
uint32(timeLock))
|
||||
int64(timeLock))
|
||||
|
||||
// Our CSV script is simply: <sequenceLock> OP_CSV OP_DROP
|
||||
// Our CSV script is simply: <sequenceLock> OP_CSV
|
||||
b := txscript.NewScriptBuilder().
|
||||
AddInt64(int64(sequenceLock)).
|
||||
AddOp(txscript.OpCheckSequenceVerify)
|
||||
@ -329,7 +293,7 @@ func createCSVOutput(r *rpctest.Harness, t *testing.T,
|
||||
// function. The sigScript is a trivial push of OP_TRUE followed by the
|
||||
// redeemScript to pass P2SH evaluation.
|
||||
func spendCSVOutput(redeemScript []byte, csvUTXO *wire.OutPoint,
|
||||
sequence uint32, targetOutput *wire.TxOut,
|
||||
sequence uint64, targetOutput *wire.TxOut,
|
||||
txVersion int32) (*wire.MsgTx, error) {
|
||||
|
||||
tx := wire.NewMsgTx(txVersion)
|
||||
@ -396,11 +360,6 @@ func TestBIP0068AndCsv(t *testing.T) {
|
||||
}
|
||||
defer r.TearDown()
|
||||
|
||||
<<<<<<< HEAD:integration/csv_fork_test.go
|
||||
assertSoftForkStatus(r, t, csvKey, blockdag.ThresholdStarted)
|
||||
|
||||
=======
|
||||
>>>>>>> origin/master:integration/csv_test.go
|
||||
harnessAddr, err := r.NewAddress()
|
||||
if err != nil {
|
||||
t.Fatalf("unable to obtain harness address: %v", err)
|
||||
@ -420,67 +379,7 @@ func TestBIP0068AndCsv(t *testing.T) {
|
||||
PkScript: harnessScript,
|
||||
}
|
||||
|
||||
<<<<<<< HEAD:integration/csv_fork_test.go
|
||||
// As the soft-fork hasn't yet activated _any_ transaction version
|
||||
// which uses the CSV opcode should be accepted. Since at this point,
|
||||
// CSV doesn't actually exist, it's just a NOP.
|
||||
for txVersion := int32(0); txVersion < 3; txVersion++ {
|
||||
// Create a trivially spendable output with a CSV lock-time of
|
||||
// 10 relative blocks.
|
||||
redeemScript, testUTXO, tx, err := createCSVOutput(r, t, outputAmt,
|
||||
relativeBlockLock, false)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create CSV encumbered output: %v", err)
|
||||
}
|
||||
|
||||
// As the transaction is p2sh it should be accepted into the
|
||||
// mempool and found within the next generated block.
|
||||
if _, err := r.Node.SendRawTransaction(tx, true); err != nil {
|
||||
t.Fatalf("unable to broadcast tx: %v", err)
|
||||
}
|
||||
blocks, err := r.Node.Generate(1)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to generate blocks: %v", err)
|
||||
}
|
||||
txid := tx.TxHash()
|
||||
assertTxInBlock(r, t, blocks[0], &txid)
|
||||
|
||||
// Generate a custom transaction which spends the CSV output.
|
||||
sequenceNum := blockdag.LockTimeToSequence(false, 10)
|
||||
spendingTx, err := spendCSVOutput(redeemScript, testUTXO,
|
||||
sequenceNum, sweepOutput, txVersion)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to spend csv output: %v", err)
|
||||
}
|
||||
|
||||
// This transaction should be rejected from the mempool since
|
||||
// CSV validation is already mempool policy pre-fork.
|
||||
_, err = r.Node.SendRawTransaction(spendingTx, true)
|
||||
if err == nil {
|
||||
t.Fatalf("transaction should have been rejected, but was " +
|
||||
"instead accepted")
|
||||
}
|
||||
|
||||
// However, this transaction should be accepted in a custom
|
||||
// generated block as CSV validation for scripts within blocks
|
||||
// shouldn't yet be active.
|
||||
txns := []*btcutil.Tx{btcutil.NewTx(spendingTx)}
|
||||
block, err := r.GenerateAndSubmitBlock(txns, -1, time.Time{})
|
||||
if err != nil {
|
||||
t.Fatalf("unable to submit block: %v", err)
|
||||
}
|
||||
txid = spendingTx.TxHash()
|
||||
assertTxInBlock(r, t, block.Hash(), &txid)
|
||||
}
|
||||
|
||||
// At this point, the block height should be 107: we started at height
|
||||
// 101, then generated 2 blocks in each loop iteration above.
|
||||
assertChainHeight(r, t, 107)
|
||||
|
||||
// With the height at 107 we need 200 blocks to be mined after the
|
||||
=======
|
||||
// With the height at 104 we need 200 blocks to be mined after the
|
||||
>>>>>>> origin/master:integration/csv_test.go
|
||||
// genesis target period, so we mine 192 blocks. This'll put us at
|
||||
// height 296. The getblockchaininfo call checks the state for the
|
||||
// block AFTER the current height.
|
||||
@ -489,12 +388,7 @@ func TestBIP0068AndCsv(t *testing.T) {
|
||||
t.Fatalf("unable to generate blocks: %v", err)
|
||||
}
|
||||
|
||||
<<<<<<< HEAD:integration/csv_fork_test.go
|
||||
assertChainHeight(r, t, 299)
|
||||
assertSoftForkStatus(r, t, csvKey, blockdag.ThresholdActive)
|
||||
=======
|
||||
assertChainHeight(r, t, 293)
|
||||
>>>>>>> origin/master:integration/csv_test.go
|
||||
|
||||
// Knowing the number of outputs needed for the tests below, create a
|
||||
// fresh output for use within each of the test-cases below.
|
||||
@ -503,7 +397,7 @@ func TestBIP0068AndCsv(t *testing.T) {
|
||||
type csvOutput struct {
|
||||
RedeemScript []byte
|
||||
Utxo *wire.OutPoint
|
||||
Timelock int32
|
||||
Timelock int64
|
||||
}
|
||||
var spendableInputs [numTests]csvOutput
|
||||
|
||||
@ -518,7 +412,7 @@ func TestBIP0068AndCsv(t *testing.T) {
|
||||
}
|
||||
|
||||
redeemScript, utxo, tx, err := createCSVOutput(r, t, outputAmt,
|
||||
int32(timeLock), isSeconds)
|
||||
timeLock, isSeconds)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to create CSV output: %v", err)
|
||||
}
|
||||
@ -530,7 +424,7 @@ func TestBIP0068AndCsv(t *testing.T) {
|
||||
spendableInputs[i] = csvOutput{
|
||||
RedeemScript: redeemScript,
|
||||
Utxo: utxo,
|
||||
Timelock: int32(timeLock),
|
||||
Timelock: int64(timeLock),
|
||||
}
|
||||
}
|
||||
|
||||
@ -562,7 +456,7 @@ func TestBIP0068AndCsv(t *testing.T) {
|
||||
// A helper function to create fully signed transactions in-line during
|
||||
// the array initialization below.
|
||||
var inputIndex uint32
|
||||
makeTxCase := func(sequenceNum uint32, txVersion int32) *wire.MsgTx {
|
||||
makeTxCase := func(sequenceNum uint64, txVersion int32) *wire.MsgTx {
|
||||
csvInput := spendableInputs[inputIndex]
|
||||
|
||||
tx, err := spendCSVOutput(csvInput.RedeemScript, csvInput.Utxo,
|
||||
@ -579,30 +473,13 @@ func TestBIP0068AndCsv(t *testing.T) {
|
||||
tx *wire.MsgTx
|
||||
accept bool
|
||||
}{
|
||||
<<<<<<< HEAD:integration/csv_fork_test.go
|
||||
// A valid transaction with a single input a sequence number
|
||||
// creating a 100 block relative time-lock. This transaction
|
||||
// should be rejected as its version number is 1, and only tx
|
||||
// of version > 2 will trigger the CSV behavior.
|
||||
{
|
||||
tx: makeTxCase(blockdag.LockTimeToSequence(false, 100), 1),
|
||||
accept: false,
|
||||
},
|
||||
// A transaction of version 2 spending a single input. The
|
||||
=======
|
||||
// A transaction spending a single input. The
|
||||
>>>>>>> origin/master:integration/csv_test.go
|
||||
// input has a relative time-lock of 1 block, but the disable
|
||||
// bit it set. The transaction should be rejected as a result.
|
||||
{
|
||||
tx: makeTxCase(
|
||||
<<<<<<< HEAD:integration/csv_fork_test.go
|
||||
blockdag.LockTimeToSequence(false, 1)|wire.SequenceLockTimeDisabled,
|
||||
2,
|
||||
=======
|
||||
blockchain.LockTimeToSequence(false, 1)|wire.SequenceLockTimeDisabled,
|
||||
1,
|
||||
>>>>>>> origin/master:integration/csv_test.go
|
||||
),
|
||||
accept: false,
|
||||
},
|
||||
@ -611,22 +488,14 @@ func TestBIP0068AndCsv(t *testing.T) {
|
||||
// but the CSV output requires a 10 block relative lock-time.
|
||||
// Therefore, the transaction should be rejected.
|
||||
{
|
||||
<<<<<<< HEAD:integration/csv_fork_test.go
|
||||
tx: makeTxCase(blockdag.LockTimeToSequence(false, 9), 2),
|
||||
=======
|
||||
tx: makeTxCase(blockchain.LockTimeToSequence(false, 9), 1),
|
||||
>>>>>>> origin/master:integration/csv_test.go
|
||||
tx: makeTxCase(blockdag.LockTimeToSequence(false, 9), 1),
|
||||
accept: false,
|
||||
},
|
||||
// A transaction with a single input having a 10 block
|
||||
// relative time lock. The referenced input is 11 blocks old so
|
||||
// the transaction should be accepted.
|
||||
{
|
||||
<<<<<<< HEAD:integration/csv_fork_test.go
|
||||
tx: makeTxCase(blockdag.LockTimeToSequence(false, 10), 2),
|
||||
=======
|
||||
tx: makeTxCase(blockchain.LockTimeToSequence(false, 10), 1),
|
||||
>>>>>>> origin/master:integration/csv_test.go
|
||||
tx: makeTxCase(blockdag.LockTimeToSequence(false, 10), 1),
|
||||
accept: true,
|
||||
},
|
||||
// A transaction with a single input having a 11 block
|
||||
@ -634,22 +503,14 @@ func TestBIP0068AndCsv(t *testing.T) {
|
||||
// 11 and the CSV op-code requires 10 blocks to have passed, so
|
||||
// this transaction should be accepted.
|
||||
{
|
||||
<<<<<<< HEAD:integration/csv_fork_test.go
|
||||
tx: makeTxCase(blockdag.LockTimeToSequence(false, 11), 2),
|
||||
=======
|
||||
tx: makeTxCase(blockchain.LockTimeToSequence(false, 11), 1),
|
||||
>>>>>>> origin/master:integration/csv_test.go
|
||||
tx: makeTxCase(blockdag.LockTimeToSequence(false, 11), 1),
|
||||
accept: true,
|
||||
},
|
||||
// A transaction whose input has a 1000 blck relative time
|
||||
// lock. This should be rejected as the input's age is only 11
|
||||
// blocks.
|
||||
{
|
||||
<<<<<<< HEAD:integration/csv_fork_test.go
|
||||
tx: makeTxCase(blockdag.LockTimeToSequence(false, 1000), 2),
|
||||
=======
|
||||
tx: makeTxCase(blockchain.LockTimeToSequence(false, 1000), 1),
|
||||
>>>>>>> origin/master:integration/csv_test.go
|
||||
tx: makeTxCase(blockdag.LockTimeToSequence(false, 1000), 1),
|
||||
accept: false,
|
||||
},
|
||||
// A transaction with a single input having a 512,000 second
|
||||
@ -657,22 +518,14 @@ func TestBIP0068AndCsv(t *testing.T) {
|
||||
// days worth of blocks haven't yet been mined. The referenced
|
||||
// input doesn't have sufficient age.
|
||||
{
|
||||
<<<<<<< HEAD:integration/csv_fork_test.go
|
||||
tx: makeTxCase(blockdag.LockTimeToSequence(true, 512000), 2),
|
||||
=======
|
||||
tx: makeTxCase(blockchain.LockTimeToSequence(true, 512000), 1),
|
||||
>>>>>>> origin/master:integration/csv_test.go
|
||||
tx: makeTxCase(blockdag.LockTimeToSequence(true, 512000), 1),
|
||||
accept: false,
|
||||
},
|
||||
// A transaction whose single input has a 512 second
|
||||
// relative time-lock. This transaction should be accepted as
|
||||
// finalized.
|
||||
{
|
||||
<<<<<<< HEAD:integration/csv_fork_test.go
|
||||
tx: makeTxCase(blockdag.LockTimeToSequence(true, 512), 2),
|
||||
=======
|
||||
tx: makeTxCase(blockchain.LockTimeToSequence(true, 512), 1),
|
||||
>>>>>>> origin/master:integration/csv_test.go
|
||||
tx: makeTxCase(blockdag.LockTimeToSequence(true, 512), 1),
|
||||
accept: true,
|
||||
},
|
||||
}
|
||||
|
@ -6,10 +6,14 @@ package mining
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/daglabs/btcd/blockdag"
|
||||
"github.com/daglabs/btcd/btcec"
|
||||
"github.com/daglabs/btcd/dagconfig"
|
||||
"github.com/daglabs/btcd/dagconfig/daghash"
|
||||
"github.com/daglabs/btcd/txscript"
|
||||
"github.com/daglabs/btcd/wire"
|
||||
"github.com/daglabs/btcutil"
|
||||
)
|
||||
@ -54,6 +58,52 @@ func newUtxoViewpoint(sourceTxns []*wire.MsgTx, sourceTxHeights []int32) *blockd
|
||||
return view
|
||||
}
|
||||
|
||||
func createTxIn(originTx *wire.MsgTx, outputIndex uint32) *wire.TxIn {
|
||||
var prevOut *wire.OutPoint
|
||||
if originTx != nil {
|
||||
originTxHash := originTx.TxHash()
|
||||
prevOut = wire.NewOutPoint(&originTxHash, 0)
|
||||
} else {
|
||||
prevOut = &wire.OutPoint{
|
||||
Hash: daghash.Hash{},
|
||||
Index: 0xFFFFFFFF,
|
||||
}
|
||||
}
|
||||
return wire.NewTxIn(prevOut, nil)
|
||||
}
|
||||
|
||||
func createTransaction(value int64, originTx *wire.MsgTx, originTxoutputIndex uint32, sigScript []byte) (*wire.MsgTx, error) {
|
||||
lookupKey := func(a btcutil.Address) (*btcec.PrivateKey, bool, error) {
|
||||
// Ordinarily this function would involve looking up the private
|
||||
// key for the provided address, but since the only thing being
|
||||
// signed in this example uses the address associated with the
|
||||
// private key from above, simply return it with the compressed
|
||||
// flag set since the address is using the associated compressed
|
||||
// public key.
|
||||
return privKey, true, nil
|
||||
}
|
||||
|
||||
tx := wire.NewMsgTx(wire.TxVersion)
|
||||
|
||||
tx.AddTxIn(createTxIn(originTx, originTxoutputIndex))
|
||||
|
||||
pkScript, err := txscript.PayToAddrScript(addr)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
txOut := wire.NewTxOut(value, pkScript)
|
||||
tx.AddTxOut(txOut)
|
||||
if sigScript == nil {
|
||||
sigScript, err = txscript.SignTxOutput(&dagconfig.MainNetParams,
|
||||
tx, 0, originTx.TxOut[0].PkScript, txscript.SigHashAll,
|
||||
txscript.KeyClosure(lookupKey), nil, nil)
|
||||
}
|
||||
tx.TxIn[0].SignatureScript = sigScript
|
||||
return tx, nil
|
||||
}
|
||||
|
||||
// TestCalcPriority ensures the priority calculations work as intended.
|
||||
func TestCalcPriority(t *testing.T) {
|
||||
// commonSourceTx1 is a valid transaction used in the tests below as an
|
||||
@ -61,59 +111,20 @@ func TestCalcPriority(t *testing.T) {
|
||||
//
|
||||
// From block 7 in main blockchain.
|
||||
// tx 0437cd7f8525ceed2324359c2d0ba26006d92d856a9c20fa0241106ee5a597c9
|
||||
commonSourceTx1 := &wire.MsgTx{
|
||||
Version: 1,
|
||||
TxIn: []*wire.TxIn{{
|
||||
PreviousOutPoint: wire.OutPoint{
|
||||
Hash: daghash.Hash{},
|
||||
Index: wire.MaxPrevOutIndex,
|
||||
},
|
||||
SignatureScript: hexToBytes("04ffff001d0134"),
|
||||
Sequence: 0xffffffff,
|
||||
}},
|
||||
TxOut: []*wire.TxOut{{
|
||||
Value: 5000000000,
|
||||
PkScript: hexToBytes("410411db93e1dcdb8a016b49840f8c5" +
|
||||
"3bc1eb68a382e97b1482ecad7b148a6909a5cb2e0ead" +
|
||||
"dfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8" +
|
||||
"643f656b412a3ac"),
|
||||
}},
|
||||
LockTime: 0,
|
||||
commonSourceTx1, err := createTransaction(5000000000, nil, 0, hexToBytes("04ffff001d0134"))
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("Error with creating source tx: %v", err)
|
||||
}
|
||||
|
||||
// commonRedeemTx1 is a valid transaction used in the tests below as the
|
||||
// transaction to calculate the priority for.
|
||||
//
|
||||
// It originally came from block 170 in main blockchain.
|
||||
commonRedeemTx1 := &wire.MsgTx{
|
||||
Version: 1,
|
||||
TxIn: []*wire.TxIn{{
|
||||
PreviousOutPoint: wire.OutPoint{
|
||||
Hash: *newHashFromStr("0437cd7f8525ceed232435" +
|
||||
"9c2d0ba26006d92d856a9c20fa0241106ee5" +
|
||||
"a597c9"),
|
||||
Index: 0,
|
||||
},
|
||||
SignatureScript: hexToBytes("47304402204e45e16932b8af" +
|
||||
"514961a1d3a1a25fdf3f4f7732e9d624c6c61548ab5f" +
|
||||
"b8cd410220181522ec8eca07de4860a4acdd12909d83" +
|
||||
"1cc56cbbac4622082221a8768d1d0901"),
|
||||
Sequence: 0xffffffff,
|
||||
}},
|
||||
TxOut: []*wire.TxOut{{
|
||||
Value: 1000000000,
|
||||
PkScript: hexToBytes("4104ae1a62fe09c5f51b13905f07f06" +
|
||||
"b99a2f7159b2225f374cd378d71302fa28414e7aab37" +
|
||||
"397f554a7df5f142c21c1b7303b8a0626f1baded5c72" +
|
||||
"a704f7e6cd84cac"),
|
||||
}, {
|
||||
Value: 4000000000,
|
||||
PkScript: hexToBytes("410411db93e1dcdb8a016b49840f8c5" +
|
||||
"3bc1eb68a382e97b1482ecad7b148a6909a5cb2e0ead" +
|
||||
"dfb84ccf9744464f82e160bfa9b8b64f9d4c03f999b8" +
|
||||
"643f656b412a3ac"),
|
||||
}},
|
||||
LockTime: 0,
|
||||
commonRedeemTx1, err := createTransaction(5000000000, commonSourceTx1, 0, nil)
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("Error with creating redeem tx: %v", err)
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
@ -129,7 +140,7 @@ func TestCalcPriority(t *testing.T) {
|
||||
utxoView: newUtxoViewpoint([]*wire.MsgTx{commonSourceTx1},
|
||||
[]int32{7}),
|
||||
nextHeight: 169,
|
||||
want: 5e9,
|
||||
want: 1.5576923076923077e+10,
|
||||
},
|
||||
{
|
||||
name: "one height 100 input, prio tx height 169",
|
||||
@ -137,7 +148,7 @@ func TestCalcPriority(t *testing.T) {
|
||||
utxoView: newUtxoViewpoint([]*wire.MsgTx{commonSourceTx1},
|
||||
[]int32{100}),
|
||||
nextHeight: 169,
|
||||
want: 2129629629.6296296,
|
||||
want: 6.634615384615385e+09,
|
||||
},
|
||||
{
|
||||
name: "one height 7 input, prio tx height 100000",
|
||||
@ -145,7 +156,7 @@ func TestCalcPriority(t *testing.T) {
|
||||
utxoView: newUtxoViewpoint([]*wire.MsgTx{commonSourceTx1},
|
||||
[]int32{7}),
|
||||
nextHeight: 100000,
|
||||
want: 3086203703703.7036,
|
||||
want: 9.61471153846154e+12,
|
||||
},
|
||||
{
|
||||
name: "one height 100 input, prio tx height 100000",
|
||||
@ -153,7 +164,7 @@ func TestCalcPriority(t *testing.T) {
|
||||
utxoView: newUtxoViewpoint([]*wire.MsgTx{commonSourceTx1},
|
||||
[]int32{100}),
|
||||
nextHeight: 100000,
|
||||
want: 3083333333333.3335,
|
||||
want: 9.60576923076923e+12,
|
||||
},
|
||||
}
|
||||
|
||||
@ -166,3 +177,11 @@ func TestCalcPriority(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var privKeyBytes, _ = hex.DecodeString("22a47fa09a223f2aa079edf85a7c2" +
|
||||
"d4f8720ee63e502ee2869afab7de234b80c")
|
||||
|
||||
var privKey, pubKey = btcec.PrivKeyFromBytes(btcec.S256(), privKeyBytes)
|
||||
var pubKeyHash = btcutil.Hash160(pubKey.SerializeCompressed())
|
||||
var addr, err = btcutil.NewAddressPubKeyHash(pubKeyHash,
|
||||
&dagconfig.MainNetParams)
|
||||
|
@ -65,7 +65,7 @@ func directionString(inbound bool) string {
|
||||
}
|
||||
|
||||
// formatLockTime returns a transaction lock time as a human-readable string.
|
||||
func formatLockTime(lockTime uint32) string {
|
||||
func formatLockTime(lockTime uint64) string {
|
||||
// The lock time field of a transaction is either a block height at
|
||||
// which the transaction is finalized or a timestamp depending on if the
|
||||
// value is before the lockTimeThreshold. When it is under the
|
||||
|
@ -239,7 +239,7 @@ func (r FutureCreateRawTransactionResult) Receive() (*wire.MsgTx, error) {
|
||||
//
|
||||
// See CreateRawTransaction for the blocking version and more details.
|
||||
func (c *Client) CreateRawTransactionAsync(inputs []btcjson.TransactionInput,
|
||||
amounts map[btcutil.Address]btcutil.Amount, lockTime *int64) FutureCreateRawTransactionResult {
|
||||
amounts map[btcutil.Address]btcutil.Amount, lockTime *uint64) FutureCreateRawTransactionResult {
|
||||
|
||||
convertedAmts := make(map[string]float64, len(amounts))
|
||||
for addr, amount := range amounts {
|
||||
@ -252,7 +252,7 @@ func (c *Client) CreateRawTransactionAsync(inputs []btcjson.TransactionInput,
|
||||
// CreateRawTransaction returns a new transaction spending the provided inputs
|
||||
// and sending to the provided addresses.
|
||||
func (c *Client) CreateRawTransaction(inputs []btcjson.TransactionInput,
|
||||
amounts map[btcutil.Address]btcutil.Amount, lockTime *int64) (*wire.MsgTx, error) {
|
||||
amounts map[btcutil.Address]btcutil.Amount, lockTime *uint64) (*wire.MsgTx, error) {
|
||||
|
||||
return c.CreateRawTransactionAsync(inputs, amounts, lockTime).Receive()
|
||||
}
|
||||
|
12
rpcserver.go
12
rpcserver.go
@ -514,7 +514,7 @@ func handleCreateRawTransaction(s *rpcServer, cmd interface{}, closeChan <-chan
|
||||
|
||||
// Validate the locktime, if given.
|
||||
if c.LockTime != nil &&
|
||||
(*c.LockTime < 0 || *c.LockTime > int64(wire.MaxTxInSequenceNum)) {
|
||||
(*c.LockTime < 0 || *c.LockTime > wire.MaxTxInSequenceNum) {
|
||||
return nil, &btcjson.RPCError{
|
||||
Code: btcjson.ErrRPCInvalidParameter,
|
||||
Message: "Locktime out of range",
|
||||
@ -599,7 +599,7 @@ func handleCreateRawTransaction(s *rpcServer, cmd interface{}, closeChan <-chan
|
||||
|
||||
// Set the Locktime, if given.
|
||||
if c.LockTime != nil {
|
||||
mtx.LockTime = uint32(*c.LockTime)
|
||||
mtx.LockTime = *c.LockTime
|
||||
}
|
||||
|
||||
// Return the serialized and hex-encoded transaction. Note that this
|
||||
@ -741,8 +741,8 @@ func createTxRawResult(chainParams *dagconfig.Params, mtx *wire.MsgTx,
|
||||
|
||||
if blkHeader != nil {
|
||||
// This is not a typo, they are identical in bitcoind as well.
|
||||
txReply.Time = blkHeader.Timestamp.Unix()
|
||||
txReply.Blocktime = blkHeader.Timestamp.Unix()
|
||||
txReply.Time = uint64(blkHeader.Timestamp.Unix())
|
||||
txReply.Blocktime = uint64(blkHeader.Timestamp.Unix())
|
||||
txReply.BlockHash = blkHash
|
||||
txReply.Confirmations = uint64(1 + chainHeight - blkHeight)
|
||||
}
|
||||
@ -3225,8 +3225,8 @@ func handleSearchRawTransactions(s *rpcServer, cmd interface{}, closeChan <-chan
|
||||
if blkHeader != nil {
|
||||
// This is not a typo, they are identical in Bitcoin
|
||||
// Core as well.
|
||||
result.Time = blkHeader.Timestamp.Unix()
|
||||
result.Blocktime = blkHeader.Timestamp.Unix()
|
||||
result.Time = uint64(blkHeader.Timestamp.Unix())
|
||||
result.Blocktime = uint64(blkHeader.Timestamp.Unix())
|
||||
result.BlockHash = blkHashStr
|
||||
result.Confirmations = uint64(1 + dagState.SelectedTip.Height - blkHeight)
|
||||
}
|
||||
|
@ -1242,575 +1242,6 @@
|
||||
["0x17 0x3014021077777777777777777777777777777777020001", "0 CHECKSIG NOT", "DERSIG", "SIG_DER", "Zero-length S is incorrectly encoded for DERSIG"],
|
||||
["0x27 0x302402107777777777777777777777777777777702108777777777777777777777777777777701", "0 CHECKSIG NOT", "DERSIG", "SIG_DER", "Negative S is incorrectly encoded for DERSIG"],
|
||||
|
||||
["Automatically generated test cases"],
|
||||
[
|
||||
"0x47 0x304402200a5c6163f07b8d3b013c4d1d6dba25e780b39658d79ba37af7057a3b7f15ffa102201fd9b4eaa9943f734928b99a83592c2e7bf342ea2680f6a2bb705167966b742001",
|
||||
"0x41 0x0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 CHECKSIG",
|
||||
"",
|
||||
"OK",
|
||||
"P2PK"
|
||||
],
|
||||
[
|
||||
"0x47 0x304402200a5c6163f07b8c3b013c4d1d6dba25e780b39658d79ba37af7057a3b7f15ffa102201fd9b4eaa9943f734928b99a83592c2e7bf342ea2680f6a2bb705167966b742001",
|
||||
"0x41 0x0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 CHECKSIG",
|
||||
"",
|
||||
"EVAL_FALSE",
|
||||
"P2PK, bad sig"
|
||||
],
|
||||
[
|
||||
"0x47 0x304402206e05a6fe23c59196ffe176c9ddc31e73a9885638f9d1328d47c0c703863b8876022076feb53811aa5b04e0e79f938eb19906cc5e67548bc555a8e8b8b0fc603d840c01 0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508",
|
||||
"DUP HASH160 0x14 0x1018853670f9f3b0582c5b9ee8ce93764ac32b93 EQUALVERIFY CHECKSIG",
|
||||
"",
|
||||
"OK",
|
||||
"P2PKH"
|
||||
],
|
||||
[
|
||||
"0x47 0x3044022034bb0494b50b8ef130e2185bb220265b9284ef5b4b8a8da4d8415df489c83b5102206259a26d9cc0a125ac26af6153b17c02956855ebe1467412f066e402f5f05d1201 0x21 0x03363d90d446b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640",
|
||||
"DUP HASH160 0x14 0xc0834c0c158f53be706d234c38fd52de7eece656 EQUALVERIFY CHECKSIG",
|
||||
"",
|
||||
"EQUALVERIFY",
|
||||
"P2PKH, bad pubkey"
|
||||
],
|
||||
[
|
||||
"0x47 0x304402204710a85181663b32d25c70ec2bbd14adff5ddfff6cb50d09e155ef5f541fc86c0220056b0cc949be9386ecc5f6c2ac0493269031dbb185781db90171b54ac127790281",
|
||||
"0x41 0x048282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f5150811f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf CHECKSIG",
|
||||
"",
|
||||
"OK",
|
||||
"P2PK anyonecanpay"
|
||||
],
|
||||
[
|
||||
"0x47 0x304402204710a85181663b32d25c70ec2bbd14adff5ddfff6cb50d09e155ef5f541fc86c0220056b0cc949be9386ecc5f6c2ac0493269031dbb185781db90171b54ac127790201",
|
||||
"0x41 0x048282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f5150811f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf CHECKSIG",
|
||||
"",
|
||||
"EVAL_FALSE",
|
||||
"P2PK anyonecanpay marked with normal hashtype"
|
||||
],
|
||||
[
|
||||
"0x47 0x3044022003fef42ed6c7be8917441218f525a60e2431be978e28b7aca4d7a532cc413ae8022067a1f82c74e8d69291b90d148778405c6257bbcfc2353cc38a3e1f22bf44254601 0x23 0x210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798ac",
|
||||
"HASH160 0x14 0x23b0ad3477f2178bc0b3eed26e4e6316f4e83aa1 EQUAL",
|
||||
"P2SH",
|
||||
"OK",
|
||||
"P2SH(P2PK)"
|
||||
],
|
||||
[
|
||||
"0x47 0x3044022003fef42ed6c7be8917441218f525a60e2431be978e28b7aca4d7a532cc413ae8022067a1f82c74e8d69291b90d148778405c6257bbcfc2353cc38a3e1f22bf44254601 0x23 0x210279be667ef9dcbbac54a06295ce870b07029bfcdb2dce28d959f2815b16f81798ac",
|
||||
"HASH160 0x14 0x23b0ad3477f2178bc0b3eed26e4e6316f4e83aa1 EQUAL",
|
||||
"P2SH",
|
||||
"EVAL_FALSE",
|
||||
"P2SH(P2PK), bad redeemscript"
|
||||
],
|
||||
[
|
||||
"0x47 0x30440220781ba4f59a7b207a10db87628bc2168df4d59b844b397d2dbc9a5835fb2f2b7602206ed8fbcc1072fe2dfc5bb25909269e5dc42ffcae7ec2bc81d59692210ff30c2b01 0x41 0x0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 0x19 0x76a91491b24bf9f5288532960ac687abb035127b1d28a588ac",
|
||||
"HASH160 0x14 0x7f67f0521934a57d3039f77f9f32cf313f3ac74b EQUAL",
|
||||
"P2SH",
|
||||
"OK",
|
||||
"P2SH(P2PKH)"
|
||||
],
|
||||
[
|
||||
"0x47 0x304402204e2eb034be7b089534ac9e798cf6a2c79f38bcb34d1b179efd6f2de0841735db022071461beb056b5a7be1819da6a3e3ce3662831ecc298419ca101eb6887b5dd6a401 0x19 0x76a9147cf9c846cd4882efec4bf07e44ebdad495c94f4b88ac",
|
||||
"HASH160 0x14 0x2df519943d5acc0ef5222091f9dfe3543f489a82 EQUAL",
|
||||
"",
|
||||
"OK",
|
||||
"P2SH(P2PKH), bad sig but no VERIFY_P2SH"
|
||||
],
|
||||
[
|
||||
"0x47 0x304402204e2eb034be7b089534ac9e798cf6a2c79f38bcb34d1b179efd6f2de0841735db022071461beb056b5a7be1819da6a3e3ce3662831ecc298419ca101eb6887b5dd6a401 0x19 0x76a9147cf9c846cd4882efec4bf07e44ebdad495c94f4b88ac",
|
||||
"HASH160 0x14 0x2df519943d5acc0ef5222091f9dfe3543f489a82 EQUAL",
|
||||
"P2SH",
|
||||
"EQUALVERIFY",
|
||||
"P2SH(P2PKH), bad sig"
|
||||
],
|
||||
[
|
||||
"0x47 0x3044022051254b9fb476a52d85530792b578f86fea70ec1ffb4393e661bcccb23d8d63d3022076505f94a403c86097841944e044c70c2045ce90e36de51f7e9d3828db98a07501 0x47 0x304402200a358f750934b3feb822f1966bfcd8bbec9eeaa3a8ca941e11ee5960e181fa01022050bf6b5a8e7750f70354ae041cb68a7bade67ec6c3ab19eb359638974410626e01 0x47 0x304402200955d031fff71d8653221e85e36c3c85533d2312fc3045314b19650b7ae2f81002202a6bb8505e36201909d0921f01abff390ae6b7ff97bbf959f98aedeb0a56730901",
|
||||
"3 0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 0x21 0x03363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640 3 CHECKMULTISIG",
|
||||
"",
|
||||
"OK",
|
||||
"3-of-3"
|
||||
],
|
||||
[
|
||||
"0x47 0x3044022051254b9fb476a52d85530792b578f86fea70ec1ffb4393e661bcccb23d8d63d3022076505f94a403c86097841944e044c70c2045ce90e36de51f7e9d3828db98a07501 0x47 0x304402200a358f750934b3feb822f1966bfcd8bbec9eeaa3a8ca941e11ee5960e181fa01022050bf6b5a8e7750f70354ae041cb68a7bade67ec6c3ab19eb359638974410626e01 0",
|
||||
"3 0x21 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 0x21 0x03363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640 3 CHECKMULTISIG",
|
||||
"",
|
||||
"EVAL_FALSE",
|
||||
"3-of-3, 2 sigs"
|
||||
],
|
||||
[
|
||||
"0 0x47 0x304402205b7d2c2f177ae76cfbbf14d589c113b0b35db753d305d5562dd0b61cbf366cfb02202e56f93c4f08a27f986cd424ffc48a462c3202c4902104d4d0ff98ed28f4bf8001 0x47 0x30440220563e5b3b1fc11662a84bc5ea2a32cc3819703254060ba30d639a1aaf2d5068ad0220601c1f47ddc76d93284dd9ed68f7c9974c4a0ea7cbe8a247d6bc3878567a5fca01 0x4c69 0x52210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f8179821038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f515082103363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff464053ae",
|
||||
"HASH160 0x14 0xc9e4a896d149702d0d1695434feddd52e24ad78d EQUAL",
|
||||
"P2SH",
|
||||
"OK",
|
||||
"P2SH(2-of-3)"
|
||||
],
|
||||
[
|
||||
"0 0x47 0x304402205b7d2c2f177ae76cfbbf14d589c113b0b35db753d305d5562dd0b61cbf366cfb02202e56f93c4f08a27f986cd424ffc48a462c3202c4902104d4d0ff98ed28f4bf8001 0 0x4c69 0x52210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f8179821038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f515082103363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff464053ae",
|
||||
"HASH160 0x14 0xc9e4a896d149702d0d1695434feddd52e24ad78d EQUAL",
|
||||
"P2SH",
|
||||
"EVAL_FALSE",
|
||||
"P2SH(2-of-3), 1 sig"
|
||||
],
|
||||
[
|
||||
"0x47 0x304402200060558477337b9022e70534f1fea71a318caf836812465a2509931c5e7c4987022078ec32bd50ac9e03a349ba953dfd9fe1c8d2dd8bdb1d38ddca844d3d5c78c11801",
|
||||
"0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 CHECKSIG",
|
||||
"",
|
||||
"OK",
|
||||
"P2PK with too much R padding but no DERSIG"
|
||||
],
|
||||
[
|
||||
"0x47 0x304402200060558477337b9022e70534f1fea71a318caf836812465a2509931c5e7c4987022078ec32bd50ac9e03a349ba953dfd9fe1c8d2dd8bdb1d38ddca844d3d5c78c11801",
|
||||
"0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 CHECKSIG",
|
||||
"DERSIG",
|
||||
"SIG_DER",
|
||||
"P2PK with too much R padding"
|
||||
],
|
||||
[
|
||||
"0x48 0x304502202de8c03fc525285c9c535631019a5f2af7c6454fa9eb392a3756a4917c420edd02210046130bf2baf7cfc065067c8b9e33a066d9c15edcea9feb0ca2d233e3597925b401",
|
||||
"0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 CHECKSIG",
|
||||
"",
|
||||
"OK",
|
||||
"P2PK with too much S padding but no DERSIG"
|
||||
],
|
||||
[
|
||||
"0x48 0x304502202de8c03fc525285c9c535631019a5f2af7c6454fa9eb392a3756a4917c420edd02210046130bf2baf7cfc065067c8b9e33a066d9c15edcea9feb0ca2d233e3597925b401",
|
||||
"0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 CHECKSIG",
|
||||
"DERSIG",
|
||||
"SIG_DER",
|
||||
"P2PK with too much S padding"
|
||||
],
|
||||
[
|
||||
"0x47 0x30440220d7a0417c3f6d1a15094d1cf2a3378ca0503eb8a57630953a9e2987e21ddd0a6502207a6266d686c99090920249991d3d42065b6d43eb70187b219c0db82e4f94d1a201",
|
||||
"0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 CHECKSIG",
|
||||
"",
|
||||
"OK",
|
||||
"P2PK with too little R padding but no DERSIG"
|
||||
],
|
||||
[
|
||||
"0x47 0x30440220d7a0417c3f6d1a15094d1cf2a3378ca0503eb8a57630953a9e2987e21ddd0a6502207a6266d686c99090920249991d3d42065b6d43eb70187b219c0db82e4f94d1a201",
|
||||
"0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 CHECKSIG",
|
||||
"DERSIG",
|
||||
"SIG_DER",
|
||||
"P2PK with too little R padding"
|
||||
],
|
||||
[
|
||||
"0x47 0x30440220005ece1335e7f757a1a1f476a7fb5bd90964e8a022489f890614a04acfb734c002206c12b8294a6513c7710e8c82d3c23d75cdbfe83200eb7efb495701958501a5d601",
|
||||
"0x21 0x03363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640 CHECKSIG NOT",
|
||||
"",
|
||||
"OK",
|
||||
"P2PK NOT with bad sig with too much R padding but no DERSIG"
|
||||
],
|
||||
[
|
||||
"0x47 0x30440220005ece1335e7f757a1a1f476a7fb5bd90964e8a022489f890614a04acfb734c002206c12b8294a6513c7710e8c82d3c23d75cdbfe83200eb7efb495701958501a5d601",
|
||||
"0x21 0x03363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640 CHECKSIG NOT",
|
||||
"DERSIG",
|
||||
"SIG_DER",
|
||||
"P2PK NOT with bad sig with too much R padding"
|
||||
],
|
||||
[
|
||||
"0x47 0x30440220005ece1335e7f657a1a1f476a7fb5bd90964e8a022489f890614a04acfb734c002206c12b8294a6513c7710e8c82d3c23d75cdbfe83200eb7efb495701958501a5d601",
|
||||
"0x21 0x03363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640 CHECKSIG NOT",
|
||||
"",
|
||||
"EVAL_FALSE",
|
||||
"P2PK NOT with too much R padding but no DERSIG"
|
||||
],
|
||||
[
|
||||
"0x47 0x30440220005ece1335e7f657a1a1f476a7fb5bd90964e8a022489f890614a04acfb734c002206c12b8294a6513c7710e8c82d3c23d75cdbfe83200eb7efb495701958501a5d601",
|
||||
"0x21 0x03363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640 CHECKSIG NOT",
|
||||
"DERSIG",
|
||||
"SIG_DER",
|
||||
"P2PK NOT with too much R padding"
|
||||
],
|
||||
[
|
||||
"0x47 0x30440220d7a0417c3f6d1a15094d1cf2a3378ca0503eb8a57630953a9e2987e21ddd0a6502207a6266d686c99090920249991d3d42065b6d43eb70187b219c0db82e4f94d1a201",
|
||||
"0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 CHECKSIG",
|
||||
"",
|
||||
"OK",
|
||||
"BIP66 example 1, without DERSIG"
|
||||
],
|
||||
[
|
||||
"0x47 0x30440220d7a0417c3f6d1a15094d1cf2a3378ca0503eb8a57630953a9e2987e21ddd0a6502207a6266d686c99090920249991d3d42065b6d43eb70187b219c0db82e4f94d1a201",
|
||||
"0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 CHECKSIG",
|
||||
"DERSIG",
|
||||
"SIG_DER",
|
||||
"BIP66 example 1, with DERSIG"
|
||||
],
|
||||
[
|
||||
"0x47 0x304402208e43c0b91f7c1e5bc58e41c8185f8a6086e111b0090187968a86f2822462d3c902200a58f4076b1133b18ff1dc83ee51676e44c60cc608d9534e0df5ace0424fc0be01",
|
||||
"0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 CHECKSIG NOT",
|
||||
"",
|
||||
"EVAL_FALSE",
|
||||
"BIP66 example 2, without DERSIG"
|
||||
],
|
||||
[
|
||||
"0x47 0x304402208e43c0b91f7c1e5bc58e41c8185f8a6086e111b0090187968a86f2822462d3c902200a58f4076b1133b18ff1dc83ee51676e44c60cc608d9534e0df5ace0424fc0be01",
|
||||
"0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 CHECKSIG NOT",
|
||||
"DERSIG",
|
||||
"SIG_DER",
|
||||
"BIP66 example 2, with DERSIG"
|
||||
],
|
||||
[
|
||||
"0",
|
||||
"0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 CHECKSIG",
|
||||
"",
|
||||
"EVAL_FALSE",
|
||||
"BIP66 example 3, without DERSIG"
|
||||
],
|
||||
[
|
||||
"0",
|
||||
"0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 CHECKSIG",
|
||||
"DERSIG",
|
||||
"EVAL_FALSE",
|
||||
"BIP66 example 3, with DERSIG"
|
||||
],
|
||||
[
|
||||
"0",
|
||||
"0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 CHECKSIG NOT",
|
||||
"",
|
||||
"OK",
|
||||
"BIP66 example 4, without DERSIG"
|
||||
],
|
||||
[
|
||||
"0",
|
||||
"0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 CHECKSIG NOT",
|
||||
"DERSIG",
|
||||
"OK",
|
||||
"BIP66 example 4, with DERSIG"
|
||||
],
|
||||
[
|
||||
"0x09 0x300602010102010101",
|
||||
"0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 CHECKSIG NOT",
|
||||
"DERSIG",
|
||||
"OK",
|
||||
"BIP66 example 4, with DERSIG, non-null DER-compliant signature"
|
||||
],
|
||||
[
|
||||
"0",
|
||||
"0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 CHECKSIG NOT",
|
||||
"DERSIG,NULLFAIL",
|
||||
"OK",
|
||||
"BIP66 example 4, with DERSIG and NULLFAIL"
|
||||
],
|
||||
[
|
||||
"0x09 0x300602010102010101",
|
||||
"0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 CHECKSIG NOT",
|
||||
"DERSIG,NULLFAIL",
|
||||
"NULLFAIL",
|
||||
"BIP66 example 4, with DERSIG and NULLFAIL, non-null DER-compliant signature"
|
||||
],
|
||||
[
|
||||
"1",
|
||||
"0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 CHECKSIG",
|
||||
"",
|
||||
"EVAL_FALSE",
|
||||
"BIP66 example 5, without DERSIG"
|
||||
],
|
||||
[
|
||||
"1",
|
||||
"0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 CHECKSIG",
|
||||
"DERSIG",
|
||||
"SIG_DER",
|
||||
"BIP66 example 5, with DERSIG"
|
||||
],
|
||||
[
|
||||
"1",
|
||||
"0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 CHECKSIG NOT",
|
||||
"",
|
||||
"OK",
|
||||
"BIP66 example 6, without DERSIG"
|
||||
],
|
||||
[
|
||||
"1",
|
||||
"0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 CHECKSIG NOT",
|
||||
"DERSIG",
|
||||
"SIG_DER",
|
||||
"BIP66 example 6, with DERSIG"
|
||||
],
|
||||
[
|
||||
"0x47 0x30440220cae00b1444babfbf6071b0ba8707f6bd373da3df494d6e74119b0430c5db810502205d5231b8c5939c8ff0c82242656d6e06edb073d42af336c99fe8837c36ea39d501 0x47 0x3044022027c2714269ca5aeecc4d70edc88ba5ee0e3da4986e9216028f489ab4f1b8efce022022bd545b4951215267e4c5ceabd4c5350331b2e4a0b6494c56f361fa5a57a1a201",
|
||||
"2 0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 0x21 0x03363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640 2 CHECKMULTISIG",
|
||||
"",
|
||||
"OK",
|
||||
"BIP66 example 7, without DERSIG"
|
||||
],
|
||||
[
|
||||
"0x47 0x30440220cae00b1444babfbf6071b0ba8707f6bd373da3df494d6e74119b0430c5db810502205d5231b8c5939c8ff0c82242656d6e06edb073d42af336c99fe8837c36ea39d501 0x47 0x3044022027c2714269ca5aeecc4d70edc88ba5ee0e3da4986e9216028f489ab4f1b8efce022022bd545b4951215267e4c5ceabd4c5350331b2e4a0b6494c56f361fa5a57a1a201",
|
||||
"2 0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 0x21 0x03363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640 2 CHECKMULTISIG",
|
||||
"DERSIG",
|
||||
"SIG_DER",
|
||||
"BIP66 example 7, with DERSIG"
|
||||
],
|
||||
[
|
||||
"0x47 0x30440220b119d67d389315308d1745f734a51ff3ec72e06081e84e236fdf9dc2f5d2a64802204b04e3bc38674c4422ea317231d642b56dc09d214a1ecbbf16ecca01ed996e2201 0x47 0x3044022079ea80afd538d9ada421b5101febeb6bc874e01dde5bca108c1d0479aec339a4022004576db8f66130d1df686ccf00935703689d69cf539438da1edab208b0d63c4801",
|
||||
"2 0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 0x21 0x03363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640 2 CHECKMULTISIG NOT",
|
||||
"",
|
||||
"EVAL_FALSE",
|
||||
"BIP66 example 8, without DERSIG"
|
||||
],
|
||||
[
|
||||
"0x47 0x30440220b119d67d389315308d1745f734a51ff3ec72e06081e84e236fdf9dc2f5d2a64802204b04e3bc38674c4422ea317231d642b56dc09d214a1ecbbf16ecca01ed996e2201 0x47 0x3044022079ea80afd538d9ada421b5101febeb6bc874e01dde5bca108c1d0479aec339a4022004576db8f66130d1df686ccf00935703689d69cf539438da1edab208b0d63c4801",
|
||||
"2 0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 0x21 0x03363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640 2 CHECKMULTISIG NOT",
|
||||
"DERSIG",
|
||||
"SIG_DER",
|
||||
"BIP66 example 8, with DERSIG"
|
||||
],
|
||||
[
|
||||
"0 0x47 0x3044022081aa9d436f2154e8b6d600516db03d78de71df685b585a9807ead4210bd883490220534bb6bdf318a419ac0749660b60e78d17d515558ef369bf872eff405b676b2e01",
|
||||
"2 0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 0x21 0x03363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640 2 CHECKMULTISIG",
|
||||
"",
|
||||
"EVAL_FALSE",
|
||||
"BIP66 example 9, without DERSIG"
|
||||
],
|
||||
[
|
||||
"0 0x47 0x3044022081aa9d436f2154e8b6d600516db03d78de71df685b585a9807ead4210bd883490220534bb6bdf318a419ac0749660b60e78d17d515558ef369bf872eff405b676b2e01",
|
||||
"2 0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 0x21 0x03363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640 2 CHECKMULTISIG",
|
||||
"DERSIG",
|
||||
"SIG_DER",
|
||||
"BIP66 example 9, with DERSIG"
|
||||
],
|
||||
[
|
||||
"0 0x47 0x30440220da6f441dc3b4b2c84cfa8db0cd5b34ed92c9e01686de5a800d40498b70c0dcac02207c2cf91b0c32b860c4cd4994be36cfb84caf8bb7c3a8e4d96a31b2022c5299c501",
|
||||
"2 0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 0x21 0x03363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640 2 CHECKMULTISIG NOT",
|
||||
"",
|
||||
"OK",
|
||||
"BIP66 example 10, without DERSIG"
|
||||
],
|
||||
[
|
||||
"0 0x47 0x30440220da6f441dc3b4b2c84cfa8db0cd5b34ed92c9e01686de5a800d40498b70c0dcac02207c2cf91b0c32b860c4cd4994be36cfb84caf8bb7c3a8e4d96a31b2022c5299c501",
|
||||
"2 0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 0x21 0x03363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640 2 CHECKMULTISIG NOT",
|
||||
"DERSIG",
|
||||
"SIG_DER",
|
||||
"BIP66 example 10, with DERSIG"
|
||||
],
|
||||
[
|
||||
"0x47 0x30440220cae00b1444babfbf6071b0ba8707f6bd373da3df494d6e74119b0430c5db810502205d5231b8c5939c8ff0c82242656d6e06edb073d42af336c99fe8837c36ea39d501 0",
|
||||
"2 0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 0x21 0x03363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640 2 CHECKMULTISIG",
|
||||
"",
|
||||
"EVAL_FALSE",
|
||||
"BIP66 example 11, without DERSIG"
|
||||
],
|
||||
[
|
||||
"0x47 0x30440220cae00b1444babfbf6071b0ba8707f6bd373da3df494d6e74119b0430c5db810502205d5231b8c5939c8ff0c82242656d6e06edb073d42af336c99fe8837c36ea39d501 0",
|
||||
"2 0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 0x21 0x03363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640 2 CHECKMULTISIG",
|
||||
"DERSIG",
|
||||
"EVAL_FALSE",
|
||||
"BIP66 example 11, with DERSIG"
|
||||
],
|
||||
[
|
||||
"0x47 0x30440220b119d67d389315308d1745f734a51ff3ec72e06081e84e236fdf9dc2f5d2a64802204b04e3bc38674c4422ea317231d642b56dc09d214a1ecbbf16ecca01ed996e2201 0",
|
||||
"2 0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 0x21 0x03363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640 2 CHECKMULTISIG NOT",
|
||||
"",
|
||||
"OK",
|
||||
"BIP66 example 12, without DERSIG"
|
||||
],
|
||||
[
|
||||
"0x47 0x30440220b119d67d389315308d1745f734a51ff3ec72e06081e84e236fdf9dc2f5d2a64802204b04e3bc38674c4422ea317231d642b56dc09d214a1ecbbf16ecca01ed996e2201 0",
|
||||
"2 0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 0x21 0x03363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640 2 CHECKMULTISIG NOT",
|
||||
"DERSIG",
|
||||
"OK",
|
||||
"BIP66 example 12, with DERSIG"
|
||||
],
|
||||
[
|
||||
"0x48 0x304402203e4516da7253cf068effec6b95c41221c0cf3a8e6ccb8cbf1725b562e9afde2c022054e1c258c2981cdfba5df1f46661fb6541c44f77ca0092f3600331abfffb12510101",
|
||||
"0x21 0x03363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640 CHECKSIG",
|
||||
"",
|
||||
"OK",
|
||||
"P2PK with multi-byte hashtype, without DERSIG"
|
||||
],
|
||||
[
|
||||
"0x48 0x304402203e4516da7253cf068effec6b95c41221c0cf3a8e6ccb8cbf1725b562e9afde2c022054e1c258c2981cdfba5df1f46661fb6541c44f77ca0092f3600331abfffb12510101",
|
||||
"0x21 0x03363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640 CHECKSIG",
|
||||
"DERSIG",
|
||||
"SIG_DER",
|
||||
"P2PK with multi-byte hashtype, with DERSIG"
|
||||
],
|
||||
[
|
||||
"0x48 0x304502203e4516da7253cf068effec6b95c41221c0cf3a8e6ccb8cbf1725b562e9afde2c022100ab1e3da73d67e32045a20e0b999e049978ea8d6ee5480d485fcf2ce0d03b2ef001",
|
||||
"0x21 0x03363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640 CHECKSIG",
|
||||
"",
|
||||
"OK",
|
||||
"P2PK with high S but no LOW_S"
|
||||
],
|
||||
[
|
||||
"0x48 0x304502203e4516da7253cf068effec6b95c41221c0cf3a8e6ccb8cbf1725b562e9afde2c022100ab1e3da73d67e32045a20e0b999e049978ea8d6ee5480d485fcf2ce0d03b2ef001",
|
||||
"0x21 0x03363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640 CHECKSIG",
|
||||
"LOW_S",
|
||||
"SIG_HIGH_S",
|
||||
"P2PK with high S"
|
||||
],
|
||||
[
|
||||
"0x47 0x3044022057292e2d4dfe775becdd0a9e6547997c728cdf35390f6a017da56d654d374e4902206b643be2fc53763b4e284845bfea2c597d2dc7759941dce937636c9d341b71ed01",
|
||||
"0x41 0x0679be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 CHECKSIG",
|
||||
"",
|
||||
"OK",
|
||||
"P2PK with hybrid pubkey but no STRICTENC"
|
||||
],
|
||||
[
|
||||
"0x47 0x3044022057292e2d4dfe775becdd0a9e6547997c728cdf35390f6a017da56d654d374e4902206b643be2fc53763b4e284845bfea2c597d2dc7759941dce937636c9d341b71ed01",
|
||||
"0x41 0x0679be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 CHECKSIG",
|
||||
"STRICTENC",
|
||||
"PUBKEYTYPE",
|
||||
"P2PK with hybrid pubkey"
|
||||
],
|
||||
[
|
||||
"0x47 0x30440220035d554e3153c14950c9993f41c496607a8e24093db0595be7bf875cf64fcf1f02204731c8c4e5daf15e706cec19cdd8f2c5b1d05490e11dab8465ed426569b6e92101",
|
||||
"0x41 0x0679be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 CHECKSIG NOT",
|
||||
"",
|
||||
"EVAL_FALSE",
|
||||
"P2PK NOT with hybrid pubkey but no STRICTENC"
|
||||
],
|
||||
[
|
||||
"0x47 0x30440220035d554e3153c14950c9993f41c496607a8e24093db0595be7bf875cf64fcf1f02204731c8c4e5daf15e706cec19cdd8f2c5b1d05490e11dab8465ed426569b6e92101",
|
||||
"0x41 0x0679be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 CHECKSIG NOT",
|
||||
"STRICTENC",
|
||||
"PUBKEYTYPE",
|
||||
"P2PK NOT with hybrid pubkey"
|
||||
],
|
||||
[
|
||||
"0x47 0x30440220035d554e3153c04950c9993f41c496607a8e24093db0595be7bf875cf64fcf1f02204731c8c4e5daf15e706cec19cdd8f2c5b1d05490e11dab8465ed426569b6e92101",
|
||||
"0x41 0x0679be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 CHECKSIG NOT",
|
||||
"",
|
||||
"OK",
|
||||
"P2PK NOT with invalid hybrid pubkey but no STRICTENC"
|
||||
],
|
||||
[
|
||||
"0x47 0x30440220035d554e3153c04950c9993f41c496607a8e24093db0595be7bf875cf64fcf1f02204731c8c4e5daf15e706cec19cdd8f2c5b1d05490e11dab8465ed426569b6e92101",
|
||||
"0x41 0x0679be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 CHECKSIG NOT",
|
||||
"STRICTENC",
|
||||
"PUBKEYTYPE",
|
||||
"P2PK NOT with invalid hybrid pubkey"
|
||||
],
|
||||
[
|
||||
"0x47 0x304402202e79441ad1baf5a07fb86bae3753184f6717d9692680947ea8b6e8b777c69af1022079a262e13d868bb5a0964fefe3ba26942e1b0669af1afb55ef3344bc9d4fc4c401",
|
||||
"1 0x41 0x0679be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 2 CHECKMULTISIG",
|
||||
"",
|
||||
"OK",
|
||||
"1-of-2 with the second 1 hybrid pubkey and no STRICTENC"
|
||||
],
|
||||
[
|
||||
"0x47 0x304402202e79441ad1baf5a07fb86bae3753184f6717d9692680947ea8b6e8b777c69af1022079a262e13d868bb5a0964fefe3ba26942e1b0669af1afb55ef3344bc9d4fc4c401",
|
||||
"1 0x41 0x0679be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 2 CHECKMULTISIG",
|
||||
"STRICTENC",
|
||||
"OK",
|
||||
"1-of-2 with the second 1 hybrid pubkey"
|
||||
],
|
||||
[
|
||||
"0x47 0x3044022079c7824d6c868e0e1a273484e28c2654a27d043c8a27f49f52cb72efed0759090220452bbbf7089574fa082095a4fc1b3a16bafcf97a3a34d745fafc922cce66b27201",
|
||||
"1 0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 0x41 0x0679be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 2 CHECKMULTISIG",
|
||||
"STRICTENC",
|
||||
"PUBKEYTYPE",
|
||||
"1-of-2 with the first 1 hybrid pubkey"
|
||||
],
|
||||
[
|
||||
"0x47 0x304402206177d513ec2cda444c021a1f4f656fc4c72ba108ae063e157eb86dc3575784940220666fc66702815d0e5413bb9b1df22aed44f5f1efb8b99d41dd5dc9a5be6d205205",
|
||||
"0x41 0x048282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f5150811f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf CHECKSIG",
|
||||
"",
|
||||
"OK",
|
||||
"P2PK with undefined hashtype but no STRICTENC"
|
||||
],
|
||||
[
|
||||
"0x47 0x304402206177d513ec2cda444c021a1f4f656fc4c72ba108ae063e157eb86dc3575784940220666fc66702815d0e5413bb9b1df22aed44f5f1efb8b99d41dd5dc9a5be6d205205",
|
||||
"0x41 0x048282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f5150811f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf CHECKSIG",
|
||||
"STRICTENC",
|
||||
"SIG_HASHTYPE",
|
||||
"P2PK with undefined hashtype"
|
||||
],
|
||||
[
|
||||
"0x47 0x304402207409b5b320296e5e2136a7b281a7f803028ca4ca44e2b83eebd46932677725de02202d4eea1c8d3c98e6f42614f54764e6e5e6542e213eb4d079737e9a8b6e9812ec05",
|
||||
"0x41 0x048282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f5150811f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf CHECKSIG NOT",
|
||||
"",
|
||||
"OK",
|
||||
"P2PK NOT with invalid sig and undefined hashtype but no STRICTENC"
|
||||
],
|
||||
[
|
||||
"0x47 0x304402207409b5b320296e5e2136a7b281a7f803028ca4ca44e2b83eebd46932677725de02202d4eea1c8d3c98e6f42614f54764e6e5e6542e213eb4d079737e9a8b6e9812ec05",
|
||||
"0x41 0x048282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f5150811f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf CHECKSIG NOT",
|
||||
"STRICTENC",
|
||||
"SIG_HASHTYPE",
|
||||
"P2PK NOT with invalid sig and undefined hashtype"
|
||||
],
|
||||
[
|
||||
"0x47 0x304402200abeb4bd07f84222f474aed558cfbdfc0b4e96cde3c2935ba7098b1ff0bd74c302204a04c1ca67b2a20abee210cf9a21023edccbbf8024b988812634233115c6b73901 DUP",
|
||||
"2 0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 2 CHECKMULTISIG",
|
||||
"",
|
||||
"OK",
|
||||
"2-of-2 with two identical keys and sigs pushed using OP_DUP but no SIGPUSHONLY"
|
||||
],
|
||||
[
|
||||
"0x47 0x304402200abeb4bd07f84222f474aed558cfbdfc0b4e96cde3c2935ba7098b1ff0bd74c302204a04c1ca67b2a20abee210cf9a21023edccbbf8024b988812634233115c6b73901 DUP",
|
||||
"2 0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 2 CHECKMULTISIG",
|
||||
"SIGPUSHONLY",
|
||||
"SIG_PUSHONLY",
|
||||
"2-of-2 with two identical keys and sigs pushed using OP_DUP"
|
||||
],
|
||||
[
|
||||
"0x47 0x3044022018a2a81a93add5cb5f5da76305718e4ea66045ec4888b28d84cb22fae7f4645b02201e6daa5ed5d2e4b2b2027cf7ffd43d8d9844dd49f74ef86899ec8e669dfd39aa01 NOP8 0x23 0x2103363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640ac",
|
||||
"HASH160 0x14 0x215640c2f72f0d16b4eced26762035a42ffed39a EQUAL",
|
||||
"",
|
||||
"OK",
|
||||
"P2SH(P2PK) with non-push scriptSig but no P2SH or SIGPUSHONLY"
|
||||
],
|
||||
[
|
||||
"0x47 0x304402203e4516da7253cf068effec6b95c41221c0cf3a8e6ccb8cbf1725b562e9afde2c022054e1c258c2981cdfba5df1f46661fb6541c44f77ca0092f3600331abfffb125101 NOP8",
|
||||
"0x21 0x03363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640 CHECKSIG",
|
||||
"",
|
||||
"OK",
|
||||
"P2PK with non-push scriptSig but with P2SH validation"
|
||||
],
|
||||
[
|
||||
"0x47 0x3044022018a2a81a93add5cb5f5da76305718e4ea66045ec4888b28d84cb22fae7f4645b02201e6daa5ed5d2e4b2b2027cf7ffd43d8d9844dd49f74ef86899ec8e669dfd39aa01 NOP8 0x23 0x2103363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640ac",
|
||||
"HASH160 0x14 0x215640c2f72f0d16b4eced26762035a42ffed39a EQUAL",
|
||||
"P2SH",
|
||||
"SIG_PUSHONLY",
|
||||
"P2SH(P2PK) with non-push scriptSig but no SIGPUSHONLY"
|
||||
],
|
||||
[
|
||||
"0x47 0x3044022018a2a81a93add5cb5f5da76305718e4ea66045ec4888b28d84cb22fae7f4645b02201e6daa5ed5d2e4b2b2027cf7ffd43d8d9844dd49f74ef86899ec8e669dfd39aa01 NOP8 0x23 0x2103363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640ac",
|
||||
"HASH160 0x14 0x215640c2f72f0d16b4eced26762035a42ffed39a EQUAL",
|
||||
"SIGPUSHONLY",
|
||||
"SIG_PUSHONLY",
|
||||
"P2SH(P2PK) with non-push scriptSig but not P2SH"
|
||||
],
|
||||
[
|
||||
"0x47 0x304402200abeb4bd07f84222f474aed558cfbdfc0b4e96cde3c2935ba7098b1ff0bd74c302204a04c1ca67b2a20abee210cf9a21023edccbbf8024b988812634233115c6b73901 0x47 0x304402200abeb4bd07f84222f474aed558cfbdfc0b4e96cde3c2935ba7098b1ff0bd74c302204a04c1ca67b2a20abee210cf9a21023edccbbf8024b988812634233115c6b73901",
|
||||
"2 0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 0x21 0x038282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508 2 CHECKMULTISIG",
|
||||
"SIGPUSHONLY",
|
||||
"OK",
|
||||
"2-of-2 with two identical keys and sigs pushed"
|
||||
],
|
||||
[
|
||||
"11 0x47 0x304402200a5c6163f07b8d3b013c4d1d6dba25e780b39658d79ba37af7057a3b7f15ffa102201fd9b4eaa9943f734928b99a83592c2e7bf342ea2680f6a2bb705167966b742001",
|
||||
"0x41 0x0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 CHECKSIG",
|
||||
"P2SH",
|
||||
"OK",
|
||||
"P2PK with unnecessary input but no CLEANSTACK"
|
||||
],
|
||||
[
|
||||
"11 0x47 0x304402200a5c6163f07b8d3b013c4d1d6dba25e780b39658d79ba37af7057a3b7f15ffa102201fd9b4eaa9943f734928b99a83592c2e7bf342ea2680f6a2bb705167966b742001",
|
||||
"0x41 0x0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 CHECKSIG",
|
||||
"CLEANSTACK,P2SH",
|
||||
"CLEANSTACK",
|
||||
"P2PK with unnecessary input"
|
||||
],
|
||||
[
|
||||
"11 0x47 0x304402202f7505132be14872581f35d74b759212d9da40482653f1ffa3116c3294a4a51702206adbf347a2240ca41c66522b1a22a41693610b76a8e7770645dc721d1635854f01 0x43 0x410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8ac",
|
||||
"HASH160 0x14 0x31edc23bdafda4639e669f89ad6b2318dd79d032 EQUAL",
|
||||
"P2SH",
|
||||
"OK",
|
||||
"P2SH with unnecessary input but no CLEANSTACK"
|
||||
],
|
||||
[
|
||||
"11 0x47 0x304402202f7505132be14872581f35d74b759212d9da40482653f1ffa3116c3294a4a51702206adbf347a2240ca41c66522b1a22a41693610b76a8e7770645dc721d1635854f01 0x43 0x410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8ac",
|
||||
"HASH160 0x14 0x31edc23bdafda4639e669f89ad6b2318dd79d032 EQUAL",
|
||||
"CLEANSTACK,P2SH",
|
||||
"CLEANSTACK",
|
||||
"P2SH with unnecessary input"
|
||||
],
|
||||
[
|
||||
"0x47 0x304402202f7505132be14872581f35d74b759212d9da40482653f1ffa3116c3294a4a51702206adbf347a2240ca41c66522b1a22a41693610b76a8e7770645dc721d1635854f01 0x43 0x410479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8ac",
|
||||
"HASH160 0x14 0x31edc23bdafda4639e669f89ad6b2318dd79d032 EQUAL",
|
||||
"CLEANSTACK,P2SH",
|
||||
"OK",
|
||||
"P2SH with CLEANSTACK"
|
||||
],
|
||||
|
||||
["CHECKSEQUENCEVERIFY tests"],
|
||||
["", "CHECKSEQUENCEVERIFY", "", "INVALID_STACK_OPERATION", "CSV automatically fails on a empty stack"],
|
||||
["-1", "CHECKSEQUENCEVERIFY", "", "NEGATIVE_LOCKTIME", "CSV automatically fails if stack top is negative"],
|
||||
|
@ -1066,7 +1066,7 @@ func opcodeReturn(op *parsedOpcode, vm *Engine) error {
|
||||
}
|
||||
|
||||
// verifyLockTime is a helper function used to validate locktimes.
|
||||
func verifyLockTime(txLockTime, threshold, lockTime int64) error {
|
||||
func verifyLockTime(txLockTime, threshold, lockTime uint64) error {
|
||||
// The lockTimes in both the script and transaction must be of the same
|
||||
// type.
|
||||
if !((txLockTime < threshold && lockTime < threshold) ||
|
||||
@ -1090,13 +1090,11 @@ func verifyLockTime(txLockTime, threshold, lockTime int64) error {
|
||||
// LockTime field of the transaction containing the script signature
|
||||
// validating if the transaction outputs are spendable yet.
|
||||
func opcodeCheckLockTimeVerify(op *parsedOpcode, vm *Engine) error {
|
||||
// The current transaction locktime is a uint32 resulting in a maximum
|
||||
// locktime of 2^32-1 (the year 2106). However, scriptNums are signed
|
||||
// The current transaction locktime is a uint64 resulting in a maximum
|
||||
// locktime of 2^63-1 (the year 292278994). However, scriptNums are signed
|
||||
// and therefore a standard 4-byte scriptNum would only support up to a
|
||||
// maximum of 2^31-1 (the year 2038). Thus, a 5-byte scriptNum is used
|
||||
// here since it will support up to 2^39-1 which allows dates beyond the
|
||||
// current locktime limit.
|
||||
//
|
||||
// here since it will support up to 2^39-1 which allows dates until the year 19400
|
||||
// PopByteArray is used here instead of PopInt because we do not want
|
||||
// to be limited to a 4-byte integer for reasons specified above.
|
||||
so, err := vm.dstack.PopByteArray()
|
||||
@ -1120,8 +1118,8 @@ func opcodeCheckLockTimeVerify(op *parsedOpcode, vm *Engine) error {
|
||||
// which the transaction is finalized or a timestamp depending on if the
|
||||
// value is before the txscript.LockTimeThreshold. When it is under the
|
||||
// threshold it is a block height.
|
||||
err = verifyLockTime(int64(vm.tx.LockTime), LockTimeThreshold,
|
||||
int64(lockTime))
|
||||
err = verifyLockTime(vm.tx.LockTime, LockTimeThreshold,
|
||||
uint64(lockTime))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1153,8 +1151,8 @@ func opcodeCheckLockTimeVerify(op *parsedOpcode, vm *Engine) error {
|
||||
// validating if the transaction outputs are spendable yet.
|
||||
func opcodeCheckSequenceVerify(op *parsedOpcode, vm *Engine) error {
|
||||
|
||||
// The current transaction sequence is a uint32 resulting in a maximum
|
||||
// sequence of 2^32-1. However, scriptNums are signed and therefore a
|
||||
// The current transaction sequence is a uint64 resulting in a maximum
|
||||
// sequence of 2^63-1. However, scriptNums are signed and therefore a
|
||||
// standard 4-byte scriptNum would only support up to a maximum of
|
||||
// 2^31-1. Thus, a 5-byte scriptNum is used here since it will support
|
||||
// up to 2^39-1 which allows sequences beyond the current sequence
|
||||
@ -1179,12 +1177,12 @@ func opcodeCheckSequenceVerify(op *parsedOpcode, vm *Engine) error {
|
||||
return scriptError(ErrNegativeLockTime, str)
|
||||
}
|
||||
|
||||
sequence := int64(stackSequence)
|
||||
sequence := uint64(stackSequence)
|
||||
|
||||
// To provide for future soft-fork extensibility, if the
|
||||
// operand has the disabled lock-time flag set,
|
||||
// CHECKSEQUENCEVERIFY behaves as a NOP.
|
||||
if sequence&int64(wire.SequenceLockTimeDisabled) != 0 {
|
||||
if sequence&uint64(wire.SequenceLockTimeDisabled) != 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -1192,15 +1190,15 @@ func opcodeCheckSequenceVerify(op *parsedOpcode, vm *Engine) error {
|
||||
// consensus constrained. Testing that the transaction's sequence
|
||||
// number does not have this bit set prevents using this property
|
||||
// to get around a CHECKSEQUENCEVERIFY check.
|
||||
txSequence := int64(vm.tx.TxIn[vm.txIdx].Sequence)
|
||||
if txSequence&int64(wire.SequenceLockTimeDisabled) != 0 {
|
||||
txSequence := vm.tx.TxIn[vm.txIdx].Sequence
|
||||
if txSequence&wire.SequenceLockTimeDisabled != 0 {
|
||||
str := fmt.Sprintf("transaction sequence has sequence "+
|
||||
"locktime disabled bit set: 0x%x", txSequence)
|
||||
return scriptError(ErrUnsatisfiedLockTime, str)
|
||||
}
|
||||
|
||||
// Mask off non-consensus bits before doing comparisons.
|
||||
lockTimeMask := int64(wire.SequenceLockTimeIsSeconds |
|
||||
lockTimeMask := uint64(wire.SequenceLockTimeIsSeconds |
|
||||
wire.SequenceLockTimeMask)
|
||||
return verifyLockTime(txSequence&lockTimeMask,
|
||||
wire.SequenceLockTimeIsSeconds, sequence&lockTimeMask)
|
||||
|
@ -5,7 +5,6 @@
|
||||
package txscript
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
@ -17,7 +16,6 @@ import (
|
||||
|
||||
"github.com/daglabs/btcd/dagconfig/daghash"
|
||||
"github.com/daglabs/btcd/wire"
|
||||
"github.com/daglabs/btcutil"
|
||||
)
|
||||
|
||||
// scriptTestName returns a descriptive test name for the given reference script
|
||||
@ -403,341 +401,3 @@ func TestScripts(t *testing.T) {
|
||||
func testVecF64ToUint32(f float64) uint32 {
|
||||
return uint32(int32(f))
|
||||
}
|
||||
|
||||
// TestTxInvalidTests ensures all of the tests in tx_invalid.json fail as
|
||||
// expected.
|
||||
func TestTxInvalidTests(t *testing.T) {
|
||||
file, err := ioutil.ReadFile("data/tx_invalid.json")
|
||||
if err != nil {
|
||||
t.Fatalf("TestTxInvalidTests: %v\n", err)
|
||||
}
|
||||
|
||||
var tests [][]interface{}
|
||||
err = json.Unmarshal(file, &tests)
|
||||
if err != nil {
|
||||
t.Fatalf("TestTxInvalidTests couldn't Unmarshal: %v\n", err)
|
||||
}
|
||||
|
||||
// form is either:
|
||||
// ["this is a comment "]
|
||||
// or:
|
||||
// [[[previous hash, previous index, previous scriptPubKey]...,]
|
||||
// serializedTransaction, verifyFlags]
|
||||
testloop:
|
||||
for i, test := range tests {
|
||||
inputs, ok := test[0].([]interface{})
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
if len(test) != 3 {
|
||||
t.Errorf("bad test (bad length) %d: %v", i, test)
|
||||
continue
|
||||
|
||||
}
|
||||
serializedhex, ok := test[1].(string)
|
||||
if !ok {
|
||||
t.Errorf("bad test (arg 2 not string) %d: %v", i, test)
|
||||
continue
|
||||
}
|
||||
serializedTx, err := hex.DecodeString(serializedhex)
|
||||
if err != nil {
|
||||
t.Errorf("bad test (arg 2 not hex %v) %d: %v", err, i,
|
||||
test)
|
||||
continue
|
||||
}
|
||||
|
||||
tx, err := btcutil.NewTxFromBytes(serializedTx)
|
||||
if err != nil {
|
||||
t.Errorf("bad test (arg 2 not msgtx %v) %d: %v", err,
|
||||
i, test)
|
||||
continue
|
||||
}
|
||||
|
||||
verifyFlags, ok := test[2].(string)
|
||||
if !ok {
|
||||
t.Errorf("bad test (arg 3 not string) %d: %v", i, test)
|
||||
continue
|
||||
}
|
||||
|
||||
flags, err := parseScriptFlags(verifyFlags)
|
||||
if err != nil {
|
||||
t.Errorf("bad test %d: %v", i, err)
|
||||
continue
|
||||
}
|
||||
|
||||
prevOuts := make(map[wire.OutPoint][]byte)
|
||||
for j, iinput := range inputs {
|
||||
input, ok := iinput.([]interface{})
|
||||
if !ok {
|
||||
t.Errorf("bad test (%dth input not array)"+
|
||||
"%d: %v", j, i, test)
|
||||
continue testloop
|
||||
}
|
||||
|
||||
if len(input) != 3 {
|
||||
t.Errorf("bad test (%dth input wrong length)"+
|
||||
"%d: %v", j, i, test)
|
||||
continue testloop
|
||||
}
|
||||
|
||||
previoustx, ok := input[0].(string)
|
||||
if !ok {
|
||||
t.Errorf("bad test (%dth input hash not string)"+
|
||||
"%d: %v", j, i, test)
|
||||
continue testloop
|
||||
}
|
||||
|
||||
prevhash, err := daghash.NewHashFromStr(previoustx)
|
||||
if err != nil {
|
||||
t.Errorf("bad test (%dth input hash not hash %v)"+
|
||||
"%d: %v", j, err, i, test)
|
||||
continue testloop
|
||||
}
|
||||
|
||||
idxf, ok := input[1].(float64)
|
||||
if !ok {
|
||||
t.Errorf("bad test (%dth input idx not number)"+
|
||||
"%d: %v", j, i, test)
|
||||
continue testloop
|
||||
}
|
||||
idx := testVecF64ToUint32(idxf)
|
||||
|
||||
oscript, ok := input[2].(string)
|
||||
if !ok {
|
||||
t.Errorf("bad test (%dth input script not "+
|
||||
"string) %d: %v", j, i, test)
|
||||
continue testloop
|
||||
}
|
||||
|
||||
script, err := parseShortForm(oscript)
|
||||
if err != nil {
|
||||
t.Errorf("bad test (%dth input script doesn't "+
|
||||
"parse %v) %d: %v", j, err, i, test)
|
||||
continue testloop
|
||||
}
|
||||
|
||||
prevOuts[*wire.NewOutPoint(prevhash, idx)] = script
|
||||
}
|
||||
|
||||
for k, txin := range tx.MsgTx().TxIn {
|
||||
pkScript, ok := prevOuts[txin.PreviousOutPoint]
|
||||
if !ok {
|
||||
t.Errorf("bad test (missing %dth input) %d:%v",
|
||||
k, i, test)
|
||||
continue testloop
|
||||
}
|
||||
// These are meant to fail, so as soon as the first
|
||||
// input fails the transaction has failed. (some of the
|
||||
// test txns have good inputs, too..
|
||||
vm, err := NewEngine(pkScript, tx.MsgTx(), k, flags, nil)
|
||||
if err != nil {
|
||||
continue testloop
|
||||
}
|
||||
|
||||
err = vm.Execute()
|
||||
if err != nil {
|
||||
continue testloop
|
||||
}
|
||||
|
||||
}
|
||||
t.Errorf("test (%d:%v) succeeded when should fail",
|
||||
i, test)
|
||||
}
|
||||
}
|
||||
|
||||
// TestTxValidTests ensures all of the tests in tx_valid.json pass as expected.
|
||||
func TestTxValidTests(t *testing.T) {
|
||||
file, err := ioutil.ReadFile("data/tx_valid.json")
|
||||
if err != nil {
|
||||
t.Fatalf("TestTxValidTests: %v\n", err)
|
||||
}
|
||||
|
||||
var tests [][]interface{}
|
||||
err = json.Unmarshal(file, &tests)
|
||||
if err != nil {
|
||||
t.Fatalf("TestTxValidTests couldn't Unmarshal: %v\n", err)
|
||||
}
|
||||
|
||||
// form is either:
|
||||
// ["this is a comment "]
|
||||
// or:
|
||||
// [[[previous hash, previous index, previous scriptPubKey]...,]
|
||||
// serializedTransaction, verifyFlags]
|
||||
testloop:
|
||||
for i, test := range tests {
|
||||
inputs, ok := test[0].([]interface{})
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
|
||||
if len(test) != 3 {
|
||||
t.Errorf("bad test (bad length) %d: %v", i, test)
|
||||
continue
|
||||
}
|
||||
serializedhex, ok := test[1].(string)
|
||||
if !ok {
|
||||
t.Errorf("bad test (arg 2 not string) %d: %v", i, test)
|
||||
continue
|
||||
}
|
||||
serializedTx, err := hex.DecodeString(serializedhex)
|
||||
if err != nil {
|
||||
t.Errorf("bad test (arg 2 not hex %v) %d: %v", err, i,
|
||||
test)
|
||||
continue
|
||||
}
|
||||
|
||||
tx, err := btcutil.NewTxFromBytes(serializedTx)
|
||||
if err != nil {
|
||||
t.Errorf("bad test (arg 2 not msgtx %v) %d: %v", err,
|
||||
i, test)
|
||||
continue
|
||||
}
|
||||
|
||||
verifyFlags, ok := test[2].(string)
|
||||
if !ok {
|
||||
t.Errorf("bad test (arg 3 not string) %d: %v", i, test)
|
||||
continue
|
||||
}
|
||||
|
||||
flags, err := parseScriptFlags(verifyFlags)
|
||||
if err != nil {
|
||||
t.Errorf("bad test %d: %v", i, err)
|
||||
continue
|
||||
}
|
||||
|
||||
prevOuts := make(map[wire.OutPoint][]byte)
|
||||
for j, iinput := range inputs {
|
||||
input, ok := iinput.([]interface{})
|
||||
if !ok {
|
||||
t.Errorf("bad test (%dth input not array)"+
|
||||
"%d: %v", j, i, test)
|
||||
continue
|
||||
}
|
||||
|
||||
if len(input) != 3 {
|
||||
t.Errorf("bad test (%dth input wrong length)"+
|
||||
"%d: %v", j, i, test)
|
||||
continue
|
||||
}
|
||||
|
||||
previoustx, ok := input[0].(string)
|
||||
if !ok {
|
||||
t.Errorf("bad test (%dth input hash not string)"+
|
||||
"%d: %v", j, i, test)
|
||||
continue
|
||||
}
|
||||
|
||||
prevhash, err := daghash.NewHashFromStr(previoustx)
|
||||
if err != nil {
|
||||
t.Errorf("bad test (%dth input hash not hash %v)"+
|
||||
"%d: %v", j, err, i, test)
|
||||
continue
|
||||
}
|
||||
|
||||
idxf, ok := input[1].(float64)
|
||||
if !ok {
|
||||
t.Errorf("bad test (%dth input idx not number)"+
|
||||
"%d: %v", j, i, test)
|
||||
continue
|
||||
}
|
||||
idx := testVecF64ToUint32(idxf)
|
||||
|
||||
oscript, ok := input[2].(string)
|
||||
if !ok {
|
||||
t.Errorf("bad test (%dth input script not "+
|
||||
"string) %d: %v", j, i, test)
|
||||
continue
|
||||
}
|
||||
|
||||
script, err := parseShortForm(oscript)
|
||||
if err != nil {
|
||||
t.Errorf("bad test (%dth input script doesn't "+
|
||||
"parse %v) %d: %v", j, err, i, test)
|
||||
continue
|
||||
}
|
||||
|
||||
prevOuts[*wire.NewOutPoint(prevhash, idx)] = script
|
||||
}
|
||||
|
||||
for k, txin := range tx.MsgTx().TxIn {
|
||||
pkScript, ok := prevOuts[txin.PreviousOutPoint]
|
||||
if !ok {
|
||||
t.Errorf("bad test (missing %dth input) %d:%v",
|
||||
k, i, test)
|
||||
continue testloop
|
||||
}
|
||||
vm, err := NewEngine(pkScript, tx.MsgTx(), k, flags, nil)
|
||||
if err != nil {
|
||||
t.Errorf("test (%d:%v:%d) failed to create "+
|
||||
"script: %v", i, test, k, err)
|
||||
continue
|
||||
}
|
||||
|
||||
err = vm.Execute()
|
||||
if err != nil {
|
||||
t.Errorf("test (%d:%v:%d) failed to execute: "+
|
||||
"%v", i, test, k, err)
|
||||
continue
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestCalcSignatureHash runs the Bitcoin Core signature hash calculation tests
|
||||
// in sighash.json.
|
||||
// https://github.com/bitcoin/bitcoin/blob/master/src/test/data/sighash.json
|
||||
func TestCalcSignatureHash(t *testing.T) {
|
||||
file, err := ioutil.ReadFile("data/sighash.json")
|
||||
if err != nil {
|
||||
t.Fatalf("TestCalcSignatureHash: %v\n", err)
|
||||
}
|
||||
|
||||
var tests [][]interface{}
|
||||
err = json.Unmarshal(file, &tests)
|
||||
if err != nil {
|
||||
t.Fatalf("TestCalcSignatureHash couldn't Unmarshal: %v\n",
|
||||
err)
|
||||
}
|
||||
|
||||
for i, test := range tests {
|
||||
if i == 0 {
|
||||
// Skip first line -- contains comments only.
|
||||
continue
|
||||
}
|
||||
if len(test) != 5 {
|
||||
t.Fatalf("TestCalcSignatureHash: Test #%d has "+
|
||||
"wrong length.", i)
|
||||
}
|
||||
var tx wire.MsgTx
|
||||
rawTx, _ := hex.DecodeString(test[0].(string))
|
||||
err := tx.Deserialize(bytes.NewReader(rawTx))
|
||||
if err != nil {
|
||||
t.Errorf("TestCalcSignatureHash failed test #%d: "+
|
||||
"Failed to parse transaction: %v", i, err)
|
||||
continue
|
||||
}
|
||||
|
||||
script, _ := hex.DecodeString(test[1].(string))
|
||||
parsedScript, err := parseScript(script)
|
||||
if err != nil {
|
||||
t.Errorf("TestCalcSignatureHash failed test #%d: "+
|
||||
"Failed to parse script: %v", i, err)
|
||||
continue
|
||||
}
|
||||
|
||||
hashType := SigHashType(testVecF64ToUint32(test[3].(float64)))
|
||||
hash, err := calcSignatureHash(parsedScript, hashType, &tx,
|
||||
int(test[2].(float64)))
|
||||
if err != nil {
|
||||
t.Errorf("TestCalcSignatureHash failed test #%d: "+
|
||||
"Failed calculating signature hash: %s", i, err)
|
||||
}
|
||||
|
||||
expectedHash, _ := daghash.NewHashFromStr(test[4].(string))
|
||||
if !bytes.Equal(hash, expectedHash[:]) {
|
||||
t.Errorf("TestCalcSignatureHash failed test #%d: "+
|
||||
"Signature hash mismatch.", i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -501,7 +501,7 @@ type AtomicSwapDataPushes struct {
|
||||
RefundHash160 [20]byte
|
||||
SecretHash [32]byte
|
||||
SecretSize int64
|
||||
LockTime int64
|
||||
LockTime uint64
|
||||
}
|
||||
|
||||
// ExtractAtomicSwapDataPushes returns the data pushes from an atomic swap
|
||||
@ -568,9 +568,9 @@ func ExtractAtomicSwapDataPushes(version uint16, pkScript []byte) (*AtomicSwapDa
|
||||
if err != nil {
|
||||
return nil, nil
|
||||
}
|
||||
pushes.LockTime = int64(locktime)
|
||||
pushes.LockTime = uint64(locktime)
|
||||
} else if op := pops[11].opcode; isSmallInt(op) {
|
||||
pushes.LockTime = int64(asSmallInt(op))
|
||||
pushes.LockTime = uint64(asSmallInt(op))
|
||||
} else {
|
||||
return nil, nil
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
"compress/bzip2"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"net"
|
||||
"os"
|
||||
"testing"
|
||||
@ -38,7 +39,7 @@ var genesisCoinbaseTx = MsgTx{
|
||||
0x6f, 0x75, 0x74, 0x20, 0x66, 0x6f, 0x72, 0x20, /* |out for |*/
|
||||
0x62, 0x61, 0x6e, 0x6b, 0x73, /* |banks| */
|
||||
},
|
||||
Sequence: 0xffffffff,
|
||||
Sequence: math.MaxUint64,
|
||||
},
|
||||
},
|
||||
TxOut: []*TxOut{
|
||||
@ -251,7 +252,7 @@ func BenchmarkReadTxIn(b *testing.B) {
|
||||
0xff, 0xff, 0xff, 0xff, // Previous output index
|
||||
0x07, // Varint for length of signature script
|
||||
0x04, 0xff, 0xff, 0x00, 0x1d, 0x01, 0x04, // Signature script
|
||||
0xff, 0xff, 0xff, 0xff, // Sequence
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // Sequence
|
||||
}
|
||||
r := bytes.NewReader(buf)
|
||||
var txIn TxIn
|
||||
@ -284,7 +285,7 @@ func BenchmarkDeserializeTxSmall(b *testing.B) {
|
||||
0xff, 0xff, 0xff, 0xff, // Prevous output index
|
||||
0x07, // Varint for length of signature script
|
||||
0x04, 0xff, 0xff, 0x00, 0x1d, 0x01, 0x04, // Signature script
|
||||
0xff, 0xff, 0xff, 0xff, // Sequence
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // Sequence
|
||||
0x01, // Varint for number of output transactions
|
||||
0x00, 0xf2, 0x05, 0x2a, 0x01, 0x00, 0x00, 0x00, // Transaction amount
|
||||
0x43, // Varint for length of pk script
|
||||
@ -297,9 +298,9 @@ func BenchmarkDeserializeTxSmall(b *testing.B) {
|
||||
0xe0, 0xa6, 0x04, 0xf8, 0x14, 0x17, 0x81, 0xe6,
|
||||
0x22, 0x94, 0x72, 0x11, 0x66, 0xbf, 0x62, 0x1e,
|
||||
0x73, 0xa8, 0x2c, 0xbf, 0x23, 0x42, 0xc8, 0x58,
|
||||
0xee, // 65-byte signature
|
||||
0xac, // OP_CHECKSIG
|
||||
0x00, 0x00, 0x00, 0x00, // Lock time
|
||||
0xee, // 65-byte signature
|
||||
0xac, // OP_CHECKSIG
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Lock time
|
||||
}
|
||||
|
||||
r := bytes.NewReader(buf)
|
||||
@ -356,7 +357,7 @@ func BenchmarkReadBlockHeader(b *testing.B) {
|
||||
0x7a, 0xc7, 0x2c, 0x3e, 0x67, 0x76, 0x8f, 0x61,
|
||||
0x7f, 0xc8, 0x1b, 0xc3, 0x88, 0x8a, 0x51, 0x32,
|
||||
0x3a, 0x9f, 0xb8, 0xaa, 0x4b, 0x1e, 0x5e, 0x4a, // MerkleRoot
|
||||
0x29, 0xab, 0x5f, 0x49, // Timestamp
|
||||
0x29, 0xab, 0x5f, 0x49, 0x00, 0x00, 0x00, 0x00, // Timestamp
|
||||
0xff, 0xff, 0x00, 0x1d, // Bits
|
||||
0xf3, 0xe0, 0x01, 0x00, // Nonce
|
||||
0x00, // TxnCount Varint
|
||||
|
@ -14,11 +14,11 @@ import (
|
||||
|
||||
// BaseBlockHeaderPayload is the base number of bytes a block header can be,
|
||||
// not including the list of previous block headers.
|
||||
// Version 4 bytes + Timestamp 4 bytes + Bits 4 bytes + Nonce 4 bytes +
|
||||
// Version 4 bytes + Timestamp 8 bytes + Bits 4 bytes + Nonce 4 bytes +
|
||||
// + NumPrevBlocks 1 byte + MerkleRoot hash.
|
||||
// To get total size of block header len(PrevBlocks) * daghash.HashSize should be
|
||||
// added to this value
|
||||
const BaseBlockHeaderPayload = 17 + (daghash.HashSize)
|
||||
const BaseBlockHeaderPayload = 21 + (daghash.HashSize)
|
||||
|
||||
// MaxNumPrevBlocks is the maximum number of previous blocks a block can reference.
|
||||
// Currently set to 255 as the maximum number NumPrevBlocks can be due to it being a byte
|
||||
@ -156,14 +156,14 @@ func readBlockHeader(r io.Reader, pver uint32, bh *BlockHeader) error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return readElements(r, &bh.MerkleRoot, (*uint32Time)(&bh.Timestamp), &bh.Bits, &bh.Nonce)
|
||||
return readElements(r, &bh.MerkleRoot, (*int64Time)(&bh.Timestamp), &bh.Bits, &bh.Nonce)
|
||||
}
|
||||
|
||||
// writeBlockHeader writes a bitcoin block header to w. See Serialize for
|
||||
// encoding block headers to be stored to disk, such as in a database, as
|
||||
// opposed to encoding for the wire.
|
||||
func writeBlockHeader(w io.Writer, pver uint32, bh *BlockHeader) error {
|
||||
sec := uint32(bh.Timestamp.Unix())
|
||||
sec := int64(bh.Timestamp.Unix())
|
||||
return writeElements(w, bh.Version, bh.NumPrevBlocks, &bh.PrevBlocks, &bh.MerkleRoot,
|
||||
sec, bh.Bits, bh.Nonce)
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ func TestBlockHeaderWire(t *testing.T) {
|
||||
0x7a, 0xc7, 0x2c, 0x3e, 0x67, 0x76, 0x8f, 0x61,
|
||||
0x7f, 0xc8, 0x1b, 0xc3, 0x88, 0x8a, 0x51, 0x32,
|
||||
0x3a, 0x9f, 0xb8, 0xaa, 0x4b, 0x1e, 0x5e, 0x4a,
|
||||
0x29, 0xab, 0x5f, 0x49, // Timestamp
|
||||
0x29, 0xab, 0x5f, 0x49, 0x00, 0x00, 0x00, 0x00, // Timestamp
|
||||
0xff, 0xff, 0x00, 0x1d, // Bits
|
||||
0xf3, 0xe0, 0x01, 0x00, // Nonce
|
||||
}
|
||||
@ -220,7 +220,7 @@ func TestBlockHeaderSerialize(t *testing.T) {
|
||||
0x7a, 0xc7, 0x2c, 0x3e, 0x67, 0x76, 0x8f, 0x61,
|
||||
0x7f, 0xc8, 0x1b, 0xc3, 0x88, 0x8a, 0x51, 0x32,
|
||||
0x3a, 0x9f, 0xb8, 0xaa, 0x4b, 0x1e, 0x5e, 0x4a,
|
||||
0x29, 0xab, 0x5f, 0x49, // Timestamp
|
||||
0x29, 0xab, 0x5f, 0x49, 0x00, 0x00, 0x00, 0x00, // Timestamp
|
||||
0xff, 0xff, 0x00, 0x1d, // Bits
|
||||
0xf3, 0xe0, 0x01, 0x00, // Nonce
|
||||
}
|
||||
@ -298,10 +298,10 @@ func TestBlockHeaderSerializeSize(t *testing.T) {
|
||||
size int // Expected serialized size
|
||||
}{
|
||||
// Block with no transactions.
|
||||
{genesisBlockHdr, 49},
|
||||
{genesisBlockHdr, 53},
|
||||
|
||||
// First block in the mainnet block chain.
|
||||
{baseBlockHdr, 113},
|
||||
{baseBlockHdr, 117},
|
||||
}
|
||||
|
||||
t.Logf("Running %d tests", len(tests))
|
||||
|
@ -176,11 +176,6 @@ var binarySerializer binaryFreeList = make(chan []byte, binaryFreeListMaxItems)
|
||||
var errNonCanonicalVarInt = "non-canonical varint %x - discriminant %x must " +
|
||||
"encode a value greater than %x"
|
||||
|
||||
// uint32Time represents a unix timestamp encoded with a uint32. It is used as
|
||||
// a way to signal the readElement function how to decode a timestamp into a Go
|
||||
// time.Time since it is otherwise ambiguous.
|
||||
type uint32Time time.Time
|
||||
|
||||
// int64Time represents a unix timestamp encoded with an int64. It is used as
|
||||
// a way to signal the readElement function how to decode a timestamp into a Go
|
||||
// time.Time since it is otherwise ambiguous.
|
||||
@ -236,15 +231,6 @@ func readElement(r io.Reader, element interface{}) error {
|
||||
}
|
||||
return nil
|
||||
|
||||
// Unix timestamp encoded as a uint32.
|
||||
case *uint32Time:
|
||||
rv, err := binarySerializer.Uint32(r, binary.LittleEndian)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
*e = uint32Time(time.Unix(int64(rv), 0))
|
||||
return nil
|
||||
|
||||
// Unix timestamp encoded as an int64.
|
||||
case *int64Time:
|
||||
rv, err := binarySerializer.Uint64(r, binary.LittleEndian)
|
||||
|
@ -89,11 +89,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, 272},
|
||||
{msgBlock, msgBlock, pver, MainNet, 284},
|
||||
{msgInv, msgInv, pver, MainNet, 25},
|
||||
{msgGetData, msgGetData, pver, MainNet, 25},
|
||||
{msgNotFound, msgNotFound, pver, MainNet, 25},
|
||||
{msgTx, msgTx, pver, MainNet, 34},
|
||||
{msgTx, msgTx, pver, MainNet, 38},
|
||||
{msgPing, msgPing, pver, MainNet, 32},
|
||||
{msgPong, msgPong, pver, MainNet, 32},
|
||||
{msgGetHeaders, msgGetHeaders, pver, MainNet, 61},
|
||||
@ -103,7 +103,7 @@ func TestMessage(t *testing.T) {
|
||||
{msgFilterAdd, msgFilterAdd, pver, MainNet, 26},
|
||||
{msgFilterClear, msgFilterClear, pver, MainNet, 24},
|
||||
{msgFilterLoad, msgFilterLoad, pver, MainNet, 35},
|
||||
{msgMerkleBlock, msgMerkleBlock, pver, MainNet, 143},
|
||||
{msgMerkleBlock, msgMerkleBlock, pver, MainNet, 147},
|
||||
{msgReject, msgReject, pver, MainNet, 79},
|
||||
{msgGetCFilters, msgGetCFilters, pver, MainNet, 61},
|
||||
{msgGetCFHeaders, msgGetCFHeaders, pver, MainNet, 61},
|
||||
|
@ -29,7 +29,7 @@ func TestAddr(t *testing.T) {
|
||||
|
||||
// Ensure max payload is expected value for latest protocol version.
|
||||
// Num addresses (varInt) + max allowed addresses.
|
||||
wantPayload := uint32(30009)
|
||||
wantPayload := uint32(34009)
|
||||
maxPayload := msg.MaxPayloadLength(pver)
|
||||
if maxPayload != wantPayload {
|
||||
t.Errorf("MaxPayloadLength: wrong max payload length for "+
|
||||
@ -124,13 +124,13 @@ func TestAddrWire(t *testing.T) {
|
||||
multiAddr := NewMsgAddr()
|
||||
multiAddr.AddAddresses(na, na2)
|
||||
multiAddrEncoded := []byte{
|
||||
0x02, // Varint for number of addresses
|
||||
0x29, 0xab, 0x5f, 0x49, // Timestamp
|
||||
0x02, // Varint for number of addresses
|
||||
0x29, 0xab, 0x5f, 0x49, 0x00, 0x00, 0x00, 0x00, // Timestamp
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // SFNodeNetwork
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x01, // IP 127.0.0.1
|
||||
0x20, 0x8d, // Port 8333 in big-endian
|
||||
0x29, 0xab, 0x5f, 0x49, // Timestamp
|
||||
0x29, 0xab, 0x5f, 0x49, 0x00, 0x00, 0x00, 0x00, // Timestamp
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // SFNodeNetwork
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xff, 0xff, 0xc0, 0xa8, 0x00, 0x01, // IP 192.168.0.1
|
||||
@ -225,13 +225,13 @@ func TestAddrWireErrors(t *testing.T) {
|
||||
baseAddr := NewMsgAddr()
|
||||
baseAddr.AddAddresses(na, na2)
|
||||
baseAddrEncoded := []byte{
|
||||
0x02, // Varint for number of addresses
|
||||
0x29, 0xab, 0x5f, 0x49, // Timestamp
|
||||
0x02, // Varint for number of addresses
|
||||
0x29, 0xab, 0x5f, 0x49, 0x00, 0x00, 0x00, 0x00, // Timestamp
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // SFNodeNetwork
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x01, // IP 127.0.0.1
|
||||
0x20, 0x8d, // Port 8333 in big-endian
|
||||
0x29, 0xab, 0x5f, 0x49, // Timestamp
|
||||
0x29, 0xab, 0x5f, 0x49, 0x00, 0x00, 0x00, 0x00, // Timestamp
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // SFNodeNetwork
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xff, 0xff, 0xc0, 0xa8, 0x00, 0x01, // IP 192.168.0.1
|
||||
|
@ -7,6 +7,7 @@ package wire
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"math"
|
||||
"reflect"
|
||||
"testing"
|
||||
"time"
|
||||
@ -71,7 +72,7 @@ func TestBlock(t *testing.T) {
|
||||
// hashes from a block accurately.
|
||||
func TestBlockTxHashes(t *testing.T) {
|
||||
// Block 1, transaction 1 hash.
|
||||
hashStr := "0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098"
|
||||
hashStr := "b7c3332bc138e2c9429818f5fed500bcc1746544218772389054dc8047d7cd3f"
|
||||
wantHash, err := daghash.NewHashFromStr(hashStr)
|
||||
if err != nil {
|
||||
t.Errorf("NewHashFromStr: %v", err)
|
||||
@ -92,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 := "2357979742c556c68e90bf624a1139af8c85cafb4ac98d6d1dc367cd661ef67d"
|
||||
hashStr := "f5a1c070bed4d87e1ff0c0040d8d56f9d559aeb4c737978b4c12a83a4c6cd231"
|
||||
wantHash, err := daghash.NewHashFromStr(hashStr)
|
||||
if err != nil {
|
||||
t.Errorf("NewHashFromStr: %v", err)
|
||||
@ -222,13 +223,13 @@ func TestBlockWireErrors(t *testing.T) {
|
||||
// Force error in timestamp.
|
||||
{&blockOne, blockOneBytes, pver, 101, io.ErrShortWrite, io.EOF},
|
||||
// Force error in difficulty bits.
|
||||
{&blockOne, blockOneBytes, pver, 105, io.ErrShortWrite, io.EOF},
|
||||
// Force error in header nonce.
|
||||
{&blockOne, blockOneBytes, pver, 109, io.ErrShortWrite, io.EOF},
|
||||
// Force error in transaction count.
|
||||
// Force error in header nonce.
|
||||
{&blockOne, blockOneBytes, pver, 113, io.ErrShortWrite, io.EOF},
|
||||
// Force error in transaction count.
|
||||
{&blockOne, blockOneBytes, pver, 117, io.ErrShortWrite, io.EOF},
|
||||
// Force error in transactions.
|
||||
{&blockOne, blockOneBytes, pver, 114, io.ErrShortWrite, io.EOF},
|
||||
{&blockOne, blockOneBytes, pver, 118, io.ErrShortWrite, io.EOF},
|
||||
}
|
||||
|
||||
t.Logf("Running %d tests", len(tests))
|
||||
@ -344,13 +345,13 @@ func TestBlockSerializeErrors(t *testing.T) {
|
||||
// Force error in timestamp.
|
||||
{&blockOne, blockOneBytes, 101, io.ErrShortWrite, io.EOF},
|
||||
// Force error in difficulty bits.
|
||||
{&blockOne, blockOneBytes, 105, io.ErrShortWrite, io.EOF},
|
||||
// Force error in header nonce.
|
||||
{&blockOne, blockOneBytes, 109, io.ErrShortWrite, io.EOF},
|
||||
// Force error in transaction count.
|
||||
// Force error in header nonce.
|
||||
{&blockOne, blockOneBytes, 113, io.ErrShortWrite, io.EOF},
|
||||
// Force error in transaction count.
|
||||
{&blockOne, blockOneBytes, 117, io.ErrShortWrite, io.EOF},
|
||||
// Force error in transactions.
|
||||
{&blockOne, blockOneBytes, 114, io.ErrShortWrite, io.EOF},
|
||||
{&blockOne, blockOneBytes, 118, io.ErrShortWrite, io.EOF},
|
||||
}
|
||||
|
||||
t.Logf("Running %d tests", len(tests))
|
||||
@ -417,7 +418,7 @@ func TestBlockOverflowErrors(t *testing.T) {
|
||||
0x7a, 0xc7, 0x2c, 0x3e, 0x67, 0x76, 0x8f, 0x61,
|
||||
0x7f, 0xc8, 0x1b, 0xc3, 0x88, 0x8a, 0x51, 0x32,
|
||||
0x3a, 0x9f, 0xb8, 0xaa, 0x4b, 0x1e, 0x5e, 0x4a,
|
||||
0x61, 0xbc, 0x66, 0x49, // Timestamp
|
||||
0x61, 0xbc, 0x66, 0x49, 0x00, 0x00, 0x00, 0x00, // Timestamp
|
||||
0xff, 0xff, 0x00, 0x1d, // Bits
|
||||
0x01, 0xe3, 0x62, 0x99, // Nonce
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
@ -469,7 +470,7 @@ func TestBlockSerializeSize(t *testing.T) {
|
||||
size int // Expected serialized size
|
||||
}{
|
||||
// Block with no transactions.
|
||||
{noTxBlock, 114},
|
||||
{noTxBlock, 118},
|
||||
|
||||
// First block in the mainnet block chain.
|
||||
{&blockOne, len(blockOneBytes)},
|
||||
@ -511,7 +512,7 @@ var blockOne = MsgBlock{
|
||||
SignatureScript: []byte{
|
||||
0x04, 0xff, 0xff, 0x00, 0x1d, 0x01, 0x04,
|
||||
},
|
||||
Sequence: 0xffffffff,
|
||||
Sequence: math.MaxUint64,
|
||||
},
|
||||
},
|
||||
TxOut: []*TxOut{
|
||||
@ -553,7 +554,7 @@ var blockOneBytes = []byte{
|
||||
0x7a, 0xc7, 0x2c, 0x3e, 0x67, 0x76, 0x8f, 0x61,
|
||||
0x7f, 0xc8, 0x1b, 0xc3, 0x88, 0x8a, 0x51, 0x32,
|
||||
0x3a, 0x9f, 0xb8, 0xaa, 0x4b, 0x1e, 0x5e, 0x4a,
|
||||
0x61, 0xbc, 0x66, 0x49, // Timestamp
|
||||
0x61, 0xbc, 0x66, 0x49, 0x00, 0x00, 0x00, 0x00, // Timestamp
|
||||
0xff, 0xff, 0x00, 0x1d, // Bits
|
||||
0x01, 0xe3, 0x62, 0x99, // Nonce
|
||||
0x01, // TxnCount
|
||||
@ -566,7 +567,7 @@ var blockOneBytes = []byte{
|
||||
0xff, 0xff, 0xff, 0xff, // Prevous output index
|
||||
0x07, // Varint for length of signature script
|
||||
0x04, 0xff, 0xff, 0x00, 0x1d, 0x01, 0x04, // Signature script (coinbase)
|
||||
0xff, 0xff, 0xff, 0xff, // Sequence
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // Sequence
|
||||
0x01, // Varint for number of transaction outputs
|
||||
0x00, 0xf2, 0x05, 0x2a, 0x01, 0x00, 0x00, 0x00, // Transaction amount
|
||||
0x43, // Varint for length of pk script
|
||||
@ -579,12 +580,12 @@ var blockOneBytes = []byte{
|
||||
0xe0, 0xa6, 0x04, 0xf8, 0x14, 0x17, 0x81, 0xe6,
|
||||
0x22, 0x94, 0x72, 0x11, 0x66, 0xbf, 0x62, 0x1e,
|
||||
0x73, 0xa8, 0x2c, 0xbf, 0x23, 0x42, 0xc8, 0x58,
|
||||
0xee, // 65-byte uncompressed public key
|
||||
0xac, // OP_CHECKSIG
|
||||
0x00, 0x00, 0x00, 0x00, // Lock time
|
||||
0xee, // 65-byte uncompressed public key
|
||||
0xac, // OP_CHECKSIG
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Lock time
|
||||
}
|
||||
|
||||
// Transaction location information for block one transactions.
|
||||
var blockOneTxLocs = []TxLoc{
|
||||
{TxStart: 114, TxLen: 134},
|
||||
{TxStart: 118, TxLen: 142},
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ func TestHeaders(t *testing.T) {
|
||||
// Ensure max payload is expected value for latest protocol version.
|
||||
// Num headers (varInt) + max allowed headers (header length + 1 byte
|
||||
// for the number of transactions which is always 0).
|
||||
wantPayload := uint32(16420009)
|
||||
wantPayload := uint32(16428009)
|
||||
maxPayload := msg.MaxPayloadLength(pver)
|
||||
if maxPayload != wantPayload {
|
||||
t.Errorf("MaxPayloadLength: wrong max payload length for "+
|
||||
@ -94,7 +94,7 @@ func TestHeadersWire(t *testing.T) {
|
||||
0x7a, 0xc7, 0x2c, 0x3e, 0x67, 0x76, 0x8f, 0x61,
|
||||
0x7f, 0xc8, 0x1b, 0xc3, 0x88, 0x8a, 0x51, 0x32,
|
||||
0x3a, 0x9f, 0xb8, 0xaa, 0x4b, 0x1e, 0x5e, 0x4a,
|
||||
0x61, 0xbc, 0x66, 0x49, // Timestamp
|
||||
0x61, 0xbc, 0x66, 0x49, 0x00, 0x00, 0x00, 0x00, // Timestamp
|
||||
0xff, 0xff, 0x00, 0x1d, // Bits
|
||||
0x01, 0xe3, 0x62, 0x99, // Nonce
|
||||
0x00, // TxnCount (0 for headers message)
|
||||
@ -250,7 +250,7 @@ func TestHeadersWireErrors(t *testing.T) {
|
||||
0x7a, 0xc7, 0x2c, 0x3e, 0x67, 0x76, 0x8f, 0x61,
|
||||
0x7f, 0xc8, 0x1b, 0xc3, 0x88, 0x8a, 0x51, 0x32,
|
||||
0x3a, 0x9f, 0xb8, 0xaa, 0x4b, 0x1e, 0x5e, 0x4a,
|
||||
0x61, 0xbc, 0x66, 0x49, // Timestamp
|
||||
0x61, 0xbc, 0x66, 0x49, 0x00, 0x00, 0x00, 0x00, // Timestamp
|
||||
0xff, 0xff, 0x00, 0x1d, // Bits
|
||||
0x01, 0xe3, 0x62, 0x99, // Nonce
|
||||
0x00, // TxnCount (0 for headers message)
|
||||
@ -291,7 +291,7 @@ func TestHeadersWireErrors(t *testing.T) {
|
||||
0x7a, 0xc7, 0x2c, 0x3e, 0x67, 0x76, 0x8f, 0x61,
|
||||
0x7f, 0xc8, 0x1b, 0xc3, 0x88, 0x8a, 0x51, 0x32,
|
||||
0x3a, 0x9f, 0xb8, 0xaa, 0x4b, 0x1e, 0x5e, 0x4a,
|
||||
0x61, 0xbc, 0x66, 0x49, // Timestamp
|
||||
0x61, 0xbc, 0x66, 0x49, 0x00, 0x00, 0x00, 0x00, // Timestamp
|
||||
0xff, 0xff, 0x00, 0x1d, // Bits
|
||||
0x01, 0xe3, 0x62, 0x99, // Nonce
|
||||
0x01, // TxnCount (should be 0 for headers message, but 1 to force error)
|
||||
|
@ -220,21 +220,21 @@ func TestMerkleBlockWireErrors(t *testing.T) {
|
||||
// Force error in timestamp.
|
||||
{&merkleBlockOne, merkleBlockOneBytes, pver, 101, io.ErrShortWrite, io.EOF},
|
||||
// Force error in difficulty bits.
|
||||
{&merkleBlockOne, merkleBlockOneBytes, pver, 105, io.ErrShortWrite, io.EOF},
|
||||
// Force error in header nonce.
|
||||
{&merkleBlockOne, merkleBlockOneBytes, pver, 109, io.ErrShortWrite, io.EOF},
|
||||
// Force error in transaction count.
|
||||
// Force error in header nonce.
|
||||
{&merkleBlockOne, merkleBlockOneBytes, pver, 113, io.ErrShortWrite, io.EOF},
|
||||
// Force error in num hashes.
|
||||
// Force error in transaction count.
|
||||
{&merkleBlockOne, merkleBlockOneBytes, pver, 117, io.ErrShortWrite, io.EOF},
|
||||
// Force error in num hashes.
|
||||
{&merkleBlockOne, merkleBlockOneBytes, pver, 121, io.ErrShortWrite, io.EOF},
|
||||
// Force error in hashes.
|
||||
{&merkleBlockOne, merkleBlockOneBytes, pver, 118, io.ErrShortWrite, io.EOF},
|
||||
{&merkleBlockOne, merkleBlockOneBytes, pver, 122, io.ErrShortWrite, io.EOF},
|
||||
// Force error in num flag bytes.
|
||||
{&merkleBlockOne, merkleBlockOneBytes, pver, 150, io.ErrShortWrite, io.EOF},
|
||||
{&merkleBlockOne, merkleBlockOneBytes, pver, 154, io.ErrShortWrite, io.EOF},
|
||||
// Force error in flag bytes.
|
||||
{&merkleBlockOne, merkleBlockOneBytes, pver, 151, io.ErrShortWrite, io.EOF},
|
||||
{&merkleBlockOne, merkleBlockOneBytes, pver, 155, io.ErrShortWrite, io.EOF},
|
||||
// Force error due to unsupported protocol version.
|
||||
{&merkleBlockOne, merkleBlockOneBytes, pverNoMerkleBlock, 151, wireErr, wireErr},
|
||||
{&merkleBlockOne, merkleBlockOneBytes, pverNoMerkleBlock, 155, wireErr, wireErr},
|
||||
}
|
||||
|
||||
t.Logf("Running %d tests", len(tests))
|
||||
@ -294,7 +294,7 @@ func TestMerkleBlockOverflowErrors(t *testing.T) {
|
||||
// allowed tx hashes.
|
||||
var buf bytes.Buffer
|
||||
WriteVarInt(&buf, pver, maxTxPerBlock+1)
|
||||
numHashesOffset := 117
|
||||
numHashesOffset := 121
|
||||
exceedMaxHashes := make([]byte, numHashesOffset)
|
||||
copy(exceedMaxHashes, merkleBlockOneBytes[:numHashesOffset])
|
||||
exceedMaxHashes = append(exceedMaxHashes, buf.Bytes()...)
|
||||
@ -303,7 +303,7 @@ func TestMerkleBlockOverflowErrors(t *testing.T) {
|
||||
// allowed flag bytes.
|
||||
buf.Reset()
|
||||
WriteVarInt(&buf, pver, maxFlagsPerMerkleBlock+1)
|
||||
numFlagBytesOffset := 150
|
||||
numFlagBytesOffset := 154
|
||||
exceedMaxFlagBytes := make([]byte, numFlagBytesOffset)
|
||||
copy(exceedMaxFlagBytes, merkleBlockOneBytes[:numFlagBytesOffset])
|
||||
exceedMaxFlagBytes = append(exceedMaxFlagBytes, buf.Bytes()...)
|
||||
@ -378,8 +378,8 @@ var merkleBlockOneBytes = []byte{
|
||||
0x98, 0x20, 0x51, 0xfd, 0x1e, 0x4b, 0xa7, 0x44, // MerkleRoot
|
||||
0xbb, 0xbe, 0x68, 0x0e, 0x1f, 0xee, 0x14, 0x67,
|
||||
0x7b, 0xa1, 0xa3, 0xc3, 0x54, 0x0b, 0xf7, 0xb1,
|
||||
0xcd, 0xb6, 0x06, 0xe8, 0x57, 0x23, 0x3e, 0x0e,
|
||||
0x61, 0xbc, 0x66, 0x49, // Timestamp
|
||||
0xcd, 0xb6, 0x06, 0xe8, 0x57, 0x23, 0x3e, 0x0e, // MerkleRoot
|
||||
0x61, 0xbc, 0x66, 0x49, 0x00, 0x00, 0x00, 0x00, // Timestamp
|
||||
0xff, 0xff, 0x00, 0x1d, // Bits
|
||||
0x01, 0xe3, 0x62, 0x99, // Nonce
|
||||
0x01, 0x00, 0x00, 0x00, // TxnCount
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"math"
|
||||
"strconv"
|
||||
|
||||
"github.com/daglabs/btcd/dagconfig/daghash"
|
||||
@ -19,7 +20,7 @@ const (
|
||||
|
||||
// MaxTxInSequenceNum is the maximum sequence number the sequence field
|
||||
// of a transaction input can be.
|
||||
MaxTxInSequenceNum uint32 = 0xffffffff
|
||||
MaxTxInSequenceNum uint64 = math.MaxUint64
|
||||
|
||||
// MaxPrevOutIndex is the maximum index the index field of a previous
|
||||
// outpoint can be.
|
||||
@ -187,16 +188,16 @@ func (o OutPoint) String() string {
|
||||
type TxIn struct {
|
||||
PreviousOutPoint OutPoint
|
||||
SignatureScript []byte
|
||||
Sequence uint32
|
||||
Sequence uint64
|
||||
}
|
||||
|
||||
// SerializeSize returns the number of bytes it would take to serialize the
|
||||
// the transaction input.
|
||||
func (t *TxIn) SerializeSize() int {
|
||||
// Outpoint Hash 32 bytes + Outpoint Index 4 bytes + Sequence 4 bytes +
|
||||
// Outpoint Hash 32 bytes + Outpoint Index 4 bytes + Sequence 8 bytes +
|
||||
// serialized varint size for the length of SignatureScript +
|
||||
// SignatureScript bytes.
|
||||
return 40 + VarIntSerializeSize(uint64(len(t.SignatureScript))) +
|
||||
return 44 + VarIntSerializeSize(uint64(len(t.SignatureScript))) +
|
||||
len(t.SignatureScript)
|
||||
}
|
||||
|
||||
@ -244,7 +245,7 @@ type MsgTx struct {
|
||||
Version int32
|
||||
TxIn []*TxIn
|
||||
TxOut []*TxOut
|
||||
LockTime uint32
|
||||
LockTime uint64
|
||||
}
|
||||
|
||||
// AddTxIn adds a transaction input to the message.
|
||||
@ -430,7 +431,8 @@ func (msg *MsgTx) BtcDecode(r io.Reader, pver uint32) error {
|
||||
totalScriptSize += uint64(len(to.PkScript))
|
||||
}
|
||||
|
||||
msg.LockTime, err = binarySerializer.Uint32(r, littleEndian)
|
||||
lockTime, err := binarySerializer.Uint64(r, littleEndian)
|
||||
msg.LockTime = lockTime
|
||||
if err != nil {
|
||||
returnScriptBuffers()
|
||||
return err
|
||||
@ -541,7 +543,7 @@ func (msg *MsgTx) BtcEncode(w io.Writer, pver uint32) error {
|
||||
}
|
||||
}
|
||||
|
||||
return binarySerializer.PutUint32(w, littleEndian, msg.LockTime)
|
||||
return binarySerializer.PutUint64(w, littleEndian, msg.LockTime)
|
||||
}
|
||||
|
||||
// Serialize encodes the transaction to w using a format that suitable for
|
||||
@ -564,9 +566,9 @@ 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 4 bytes + Serialized varint size for the
|
||||
// Version 4 bytes + LockTime 8 bytes + Serialized varint size for the
|
||||
// number of transaction inputs and outputs.
|
||||
n := 8 + VarIntSerializeSize(uint64(len(msg.TxIn))) +
|
||||
n := 12 + VarIntSerializeSize(uint64(len(msg.TxIn))) +
|
||||
VarIntSerializeSize(uint64(len(msg.TxOut)))
|
||||
|
||||
for _, txIn := range msg.TxIn {
|
||||
@ -726,7 +728,7 @@ func writeTxIn(w io.Writer, pver uint32, version int32, ti *TxIn) error {
|
||||
return err
|
||||
}
|
||||
|
||||
return binarySerializer.PutUint32(w, littleEndian, ti.Sequence)
|
||||
return binarySerializer.PutUint64(w, littleEndian, ti.Sequence)
|
||||
}
|
||||
|
||||
// readTxOut reads the next sequence of bytes from r as a transaction output
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"math"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
@ -128,7 +129,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 := "f051e59b5e2503ac626d03aaeac8ab7be2d72ba4b7e97119c5852d70d52dcb86"
|
||||
hashStr := "768f7e5de1e0a209c9f4e89a5b610d15e888dfe8f32be7f92462edc5815fc025"
|
||||
wantHash, err := daghash.NewHashFromStr(hashStr)
|
||||
if err != nil {
|
||||
t.Errorf("NewHashFromStr: %v", err)
|
||||
@ -143,7 +144,7 @@ func TestTxHash(t *testing.T) {
|
||||
Index: 0xffffffff,
|
||||
},
|
||||
SignatureScript: []byte{0x04, 0x31, 0xdc, 0x00, 0x1b, 0x01, 0x62},
|
||||
Sequence: 0xffffffff,
|
||||
Sequence: math.MaxUint64,
|
||||
}
|
||||
txOut := TxOut{
|
||||
Value: 5000000000,
|
||||
@ -181,9 +182,9 @@ func TestTxWire(t *testing.T) {
|
||||
noTx.Version = 1
|
||||
noTxEncoded := []byte{
|
||||
0x01, 0x00, 0x00, 0x00, // Version
|
||||
0x00, // Varint for number of input transactions
|
||||
0x00, // Varint for number of output transactions
|
||||
0x00, 0x00, 0x00, 0x00, // Lock time
|
||||
0x00, // Varint for number of input transactions
|
||||
0x00, // Varint for number of output transactions
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Lock time
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
@ -334,15 +335,15 @@ func TestTxWireErrors(t *testing.T) {
|
||||
// Force error in transaction input sequence.
|
||||
{multiTx, multiTxEncoded, pver, 49, io.ErrShortWrite, io.EOF},
|
||||
// Force error in number of transaction outputs.
|
||||
{multiTx, multiTxEncoded, pver, 53, io.ErrShortWrite, io.EOF},
|
||||
{multiTx, multiTxEncoded, pver, 57, io.ErrShortWrite, io.EOF},
|
||||
// Force error in transaction output value.
|
||||
{multiTx, multiTxEncoded, pver, 54, io.ErrShortWrite, io.EOF},
|
||||
{multiTx, multiTxEncoded, pver, 58, io.ErrShortWrite, io.EOF},
|
||||
// Force error in transaction output pk script length.
|
||||
{multiTx, multiTxEncoded, pver, 62, io.ErrShortWrite, io.EOF},
|
||||
{multiTx, multiTxEncoded, pver, 66, io.ErrShortWrite, io.EOF},
|
||||
// Force error in transaction output pk script.
|
||||
{multiTx, multiTxEncoded, pver, 63, io.ErrShortWrite, io.EOF},
|
||||
{multiTx, multiTxEncoded, pver, 67, io.ErrShortWrite, io.EOF},
|
||||
// Force error in transaction output lock time.
|
||||
{multiTx, multiTxEncoded, pver, 206, io.ErrShortWrite, io.EOF},
|
||||
{multiTx, multiTxEncoded, pver, 210, io.ErrShortWrite, io.EOF},
|
||||
}
|
||||
|
||||
t.Logf("Running %d tests", len(tests))
|
||||
@ -374,9 +375,9 @@ func TestTxSerialize(t *testing.T) {
|
||||
noTx.Version = 1
|
||||
noTxEncoded := []byte{
|
||||
0x01, 0x00, 0x00, 0x00, // Version
|
||||
0x00, // Varint for number of input transactions
|
||||
0x00, // Varint for number of output transactions
|
||||
0x00, 0x00, 0x00, 0x00, // Lock time
|
||||
0x00, // Varint for number of input transactions
|
||||
0x00, // Varint for number of output transactions
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Lock time
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
@ -477,15 +478,15 @@ func TestTxSerializeErrors(t *testing.T) {
|
||||
// Force error in transaction input sequence.
|
||||
{multiTx, multiTxEncoded, 49, io.ErrShortWrite, io.EOF},
|
||||
// Force error in number of transaction outputs.
|
||||
{multiTx, multiTxEncoded, 53, io.ErrShortWrite, io.EOF},
|
||||
{multiTx, multiTxEncoded, 57, io.ErrShortWrite, io.EOF},
|
||||
// Force error in transaction output value.
|
||||
{multiTx, multiTxEncoded, 54, io.ErrShortWrite, io.EOF},
|
||||
{multiTx, multiTxEncoded, 58, io.ErrShortWrite, io.EOF},
|
||||
// Force error in transaction output pk script length.
|
||||
{multiTx, multiTxEncoded, 62, io.ErrShortWrite, io.EOF},
|
||||
{multiTx, multiTxEncoded, 66, io.ErrShortWrite, io.EOF},
|
||||
// Force error in transaction output pk script.
|
||||
{multiTx, multiTxEncoded, 63, io.ErrShortWrite, io.EOF},
|
||||
{multiTx, multiTxEncoded, 67, io.ErrShortWrite, io.EOF},
|
||||
// Force error in transaction output lock time.
|
||||
{multiTx, multiTxEncoded, 206, io.ErrShortWrite, io.EOF},
|
||||
{multiTx, multiTxEncoded, 210, io.ErrShortWrite, io.EOF},
|
||||
}
|
||||
|
||||
t.Logf("Running %d tests", len(tests))
|
||||
@ -574,8 +575,8 @@ func TestTxOverflowErrors(t *testing.T) {
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Previous output hash
|
||||
0xff, 0xff, 0xff, 0xff, // Prevous output index
|
||||
0x00, // Varint for length of signature script
|
||||
0xff, 0xff, 0xff, 0xff, // Sequence
|
||||
0x00, // Varint for length of signature script
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // Sequence
|
||||
0x01, // Varint for number of output transactions
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Transaction amount
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
||||
@ -619,10 +620,10 @@ func TestTxSerializeSize(t *testing.T) {
|
||||
size int // Expected serialized size
|
||||
}{
|
||||
// No inputs or outpus.
|
||||
{noTx, 10},
|
||||
{noTx, 14},
|
||||
|
||||
// Transcaction with an input and an output.
|
||||
{multiTx, 210},
|
||||
{multiTx, 218},
|
||||
}
|
||||
|
||||
t.Logf("Running %d tests", len(tests))
|
||||
@ -648,7 +649,7 @@ var multiTx = &MsgTx{
|
||||
SignatureScript: []byte{
|
||||
0x04, 0x31, 0xdc, 0x00, 0x1b, 0x01, 0x62,
|
||||
},
|
||||
Sequence: 0xffffffff,
|
||||
Sequence: math.MaxUint64,
|
||||
},
|
||||
},
|
||||
TxOut: []*TxOut{
|
||||
@ -700,7 +701,7 @@ var multiTxEncoded = []byte{
|
||||
0xff, 0xff, 0xff, 0xff, // Prevous output index
|
||||
0x07, // Varint for length of signature script
|
||||
0x04, 0x31, 0xdc, 0x00, 0x1b, 0x01, 0x62, // Signature script
|
||||
0xff, 0xff, 0xff, 0xff, // Sequence
|
||||
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, // Sequence
|
||||
0x02, // Varint for number of output transactions
|
||||
0x00, 0xf2, 0x05, 0x2a, 0x01, 0x00, 0x00, 0x00, // Transaction amount
|
||||
0x43, // Varint for length of pk script
|
||||
@ -726,11 +727,11 @@ var multiTxEncoded = []byte{
|
||||
0x3d, 0x81, 0xb0, 0x1c, 0xc3, 0x1f, 0x04, 0x78,
|
||||
0x34, 0xbc, 0x06, 0xd6, 0xd6, 0xed, 0xf6, 0x20,
|
||||
0xd1, 0x84, 0x24, 0x1a, 0x6a, 0xed, 0x8b, 0x63,
|
||||
0xa6, // 65-byte signature
|
||||
0xac, // OP_CHECKSIG
|
||||
0x00, 0x00, 0x00, 0x00, // Lock time
|
||||
0xa6, // 65-byte signature
|
||||
0xac, // OP_CHECKSIG
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Lock time
|
||||
}
|
||||
|
||||
// multiTxPkScriptLocs is the location information for the public key scripts
|
||||
// located in multiTx.
|
||||
var multiTxPkScriptLocs = []int{63, 139}
|
||||
var multiTxPkScriptLocs = []int{67, 143}
|
||||
|
@ -209,7 +209,7 @@ func (msg *MsgVersion) Command() string {
|
||||
func (msg *MsgVersion) MaxPayloadLength(pver uint32) uint32 {
|
||||
// XXX: <= 106 different
|
||||
|
||||
// Protocol version 4 bytes + services 8 bytes + timestamp 8 bytes +
|
||||
// Protocol version 4 bytes + services 8 bytes + timestamp 16 bytes +
|
||||
// remote and local net addresses + nonce 8 bytes + length of user
|
||||
// agent (varInt) + max allowed useragent length + last block 4 bytes +
|
||||
// relay transactions flag 1 byte.
|
||||
|
@ -103,11 +103,11 @@ func TestVersion(t *testing.T) {
|
||||
}
|
||||
|
||||
// Ensure max payload is expected value.
|
||||
// Protocol version 4 bytes + services 8 bytes + timestamp 8 bytes +
|
||||
// Protocol version 4 bytes + services 8 bytes + timestamp 16 bytes +
|
||||
// remote and local net addresses + nonce 8 bytes + length of user agent
|
||||
// (varInt) + max allowed user agent length + last block 4 bytes +
|
||||
// relay transactions flag 1 byte.
|
||||
wantPayload := uint32(358)
|
||||
wantPayload := uint32(366)
|
||||
maxPayload := msg.MaxPayloadLength(pver)
|
||||
if maxPayload != wantPayload {
|
||||
t.Errorf("MaxPayloadLength: wrong max payload length for "+
|
||||
|
@ -19,8 +19,8 @@ func maxNetAddressPayload(pver uint32) uint32 {
|
||||
|
||||
// NetAddressTimeVersion added a timestamp field.
|
||||
if pver >= NetAddressTimeVersion {
|
||||
// Timestamp 4 bytes.
|
||||
plen += 4
|
||||
// Timestamp 8 bytes.
|
||||
plen += 8
|
||||
}
|
||||
|
||||
return plen
|
||||
@ -29,10 +29,7 @@ func maxNetAddressPayload(pver uint32) uint32 {
|
||||
// NetAddress defines information about a peer on the network including the time
|
||||
// it was last seen, the services it supports, its IP address, and port.
|
||||
type NetAddress struct {
|
||||
// Last time the address was seen. This is, unfortunately, encoded as a
|
||||
// uint32 on the wire and therefore is limited to 2106. This field is
|
||||
// not present in the bitcoin version message (MsgVersion) nor was it
|
||||
// added until protocol version >= NetAddressTimeVersion.
|
||||
// Last time the address was seen.
|
||||
Timestamp time.Time
|
||||
|
||||
// Bitfield which identifies the services supported by the address.
|
||||
@ -91,11 +88,8 @@ func NewNetAddress(addr *net.TCPAddr, services ServiceFlag) *NetAddress {
|
||||
func readNetAddress(r io.Reader, pver uint32, na *NetAddress, ts bool) error {
|
||||
var ip [16]byte
|
||||
|
||||
// NOTE: The bitcoin protocol uses a uint32 for the timestamp so it will
|
||||
// stop working somewhere around 2106. Also timestamp wasn't added until
|
||||
// protocol version >= NetAddressTimeVersion
|
||||
if ts && pver >= NetAddressTimeVersion {
|
||||
err := readElement(r, (*uint32Time)(&na.Timestamp))
|
||||
err := readElement(r, (*int64Time)(&na.Timestamp))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -124,11 +118,9 @@ func readNetAddress(r io.Reader, pver uint32, na *NetAddress, ts bool) error {
|
||||
// version and whether or not the timestamp is included per ts. Some messages
|
||||
// like version do not include the timestamp.
|
||||
func writeNetAddress(w io.Writer, pver uint32, na *NetAddress, ts bool) error {
|
||||
// NOTE: The bitcoin protocol uses a uint32 for the timestamp so it will
|
||||
// stop working somewhere around 2106. Also timestamp wasn't added until
|
||||
// until protocol version >= NetAddressTimeVersion.
|
||||
// Timestamp wasn't added until protocol version >= NetAddressTimeVersion.
|
||||
if ts && pver >= NetAddressTimeVersion {
|
||||
err := writeElement(w, uint32(na.Timestamp.Unix()))
|
||||
err := writeElement(w, int64(na.Timestamp.Unix()))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ func TestNetAddress(t *testing.T) {
|
||||
|
||||
// Ensure max payload is expected value for latest protocol version.
|
||||
pver := ProtocolVersion
|
||||
wantPayload := uint32(30)
|
||||
wantPayload := uint32(34)
|
||||
maxPayload := maxNetAddressPayload(ProtocolVersion)
|
||||
if maxPayload != wantPayload {
|
||||
t.Errorf("maxNetAddressPayload: wrong max payload length for "+
|
||||
@ -88,7 +88,7 @@ func TestNetAddressWire(t *testing.T) {
|
||||
|
||||
// baseNetAddrEncoded is the wire encoded bytes of baseNetAddr.
|
||||
baseNetAddrEncoded := []byte{
|
||||
0x29, 0xab, 0x5f, 0x49, // Timestamp
|
||||
0x29, 0xab, 0x5f, 0x49, 0x00, 0x00, 0x00, 0x00, // Timestamp
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // SFNodeNetwork
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x01, // IP 127.0.0.1
|
||||
@ -228,11 +228,11 @@ func TestNetAddressWireErrors(t *testing.T) {
|
||||
// Force errors on timestamp.
|
||||
{&baseNetAddr, []byte{}, pver, true, 0, io.ErrShortWrite, io.EOF},
|
||||
// Force errors on services.
|
||||
{&baseNetAddr, []byte{}, pver, true, 4, io.ErrShortWrite, io.EOF},
|
||||
{&baseNetAddr, []byte{}, pver, true, 8, io.ErrShortWrite, io.EOF},
|
||||
// Force errors on ip.
|
||||
{&baseNetAddr, []byte{}, pver, true, 12, io.ErrShortWrite, io.EOF},
|
||||
{&baseNetAddr, []byte{}, pver, true, 16, io.ErrShortWrite, io.EOF},
|
||||
// Force errors on port.
|
||||
{&baseNetAddr, []byte{}, pver, true, 28, io.ErrShortWrite, io.EOF},
|
||||
{&baseNetAddr, []byte{}, pver, true, 32, io.ErrShortWrite, io.EOF},
|
||||
|
||||
// Latest protocol version with no timestamp and intentional
|
||||
// read/write errors.
|
||||
|
Loading…
x
Reference in New Issue
Block a user