github.com/aychain/blockbook@v0.1.1-0.20181121092459-6d1fc7e07c5b/tests/dbtestdata/dbtestdata.go (about)

     1  package dbtestdata
     2  
     3  import (
     4  	"blockbook/bchain"
     5  	"encoding/hex"
     6  	"math/big"
     7  
     8  	"github.com/golang/glog"
     9  )
    10  
    11  const (
    12  	TxidB1T1 = "00b2c06055e5e90e9c82bd4181fde310104391a7fa4f289b1704e5d90caa3840"
    13  	TxidB1T2 = "effd9ef509383d536b1c8af5bf434c8efbf521a4f2befd4022bbd68694b4ac75"
    14  	TxidB2T1 = "7c3be24063f268aaa1ed81b64776798f56088757641a34fb156c4f51ed2e9d25"
    15  	TxidB2T2 = "3d90d15ed026dc45e19ffb52875ed18fa9e8012ad123d7f7212176e2b0ebdb71"
    16  	TxidB2T3 = "05e2e48aeabdd9b75def7b48d756ba304713c2aba7b522bf9dbc893fc4231b07"
    17  	TxidB2T4 = "fdd824a780cbb718eeb766eb05d83fdefc793a27082cd5e67f856d69798cf7db"
    18  
    19  	Addr1 = "mfcWp7DB6NuaZsExybTTXpVgWz559Np4Ti"  // 76a914010d39800f86122416e28f485029acf77507169288ac
    20  	Addr2 = "mtGXQvBowMkBpnhLckhxhbwYK44Gs9eEtz"  // 76a9148bdf0aa3c567aa5975c2e61321b8bebbe7293df688ac
    21  	Addr3 = "mv9uLThosiEnGRbVPS7Vhyw6VssbVRsiAw"  // 76a914a08eae93007f22668ab5e4a9c83c8cd1c325e3e088ac
    22  	Addr4 = "2Mz1CYoppGGsLNUGF2YDhTif6J661JitALS" // a9144a21db08fb6882cb152e1ff06780a430740f770487
    23  	Addr5 = "2NEVv9LJmAnY99W1pFoc5UJjVdypBqdnvu1" // a914e921fc4912a315078f370d959f2c4f7b6d2a683c87
    24  	Addr6 = "mzB8cYrfRwFRFAGTDzV8LkUQy5BQicxGhX"  // 76a914ccaaaf374e1b06cb83118453d102587b4273d09588ac
    25  	Addr7 = "mtR97eM2HPWVM6c8FGLGcukgaHHQv7THoL"  // 76a9148d802c045445df49613f6a70ddd2e48526f3701f88ac
    26  	Addr8 = "mwwoKQE5Lb1G4picHSHDQKg8jw424PF9SC"  // 76a914b434eb0c1a3b7a02e8a29cc616e791ef1e0bf51f88ac
    27  	Addr9 = "mmJx9Y8ayz9h14yd9fgCW1bUKoEpkBAquP"  // 76a9143f8ba3fda3ba7b69f5818086e12223c6dd25e3c888ac
    28  	AddrA = "mzVznVsCHkVHX9UN8WPFASWUUHtxnNn4Jj"  // 76a914d03c0d863d189b23b061a95ad32940b65837609f88ac
    29  )
    30  
    31  var (
    32  	SatZero   = big.NewInt(0)
    33  	SatB1T1A1 = big.NewInt(100000000)
    34  	SatB1T1A2 = big.NewInt(12345)
    35  	SatB1T2A3 = big.NewInt(1234567890123)
    36  	SatB1T2A4 = big.NewInt(1)
    37  	SatB1T2A5 = big.NewInt(9876)
    38  	SatB2T1A6 = big.NewInt(317283951061)
    39  	SatB2T1A7 = big.NewInt(917283951061)
    40  	SatB2T2A8 = big.NewInt(118641975500)
    41  	SatB2T2A9 = big.NewInt(198641975500)
    42  	SatB2T3A5 = big.NewInt(9000)
    43  	SatB2T4AA = big.NewInt(1360030331)
    44  )
    45  
    46  func AddressToPubKeyHex(addr string, parser bchain.BlockChainParser) string {
    47  	if addr == "" {
    48  		return ""
    49  	}
    50  	b, err := parser.GetAddrDescFromAddress(addr)
    51  	if err != nil {
    52  		glog.Fatal(err)
    53  	}
    54  	return hex.EncodeToString(b)
    55  }
    56  
    57  func GetTestUTXOBlock1(parser bchain.BlockChainParser) *bchain.Block {
    58  	return &bchain.Block{
    59  		BlockHeader: bchain.BlockHeader{
    60  			Height:        225493,
    61  			Hash:          "0000000076fbbed90fd75b0e18856aa35baa984e9c9d444cf746ad85e94e2997",
    62  			Size:          1234567,
    63  			Time:          1534858021,
    64  			Confirmations: 2,
    65  		},
    66  		Txs: []bchain.Tx{
    67  			bchain.Tx{
    68  				Txid: TxidB1T1,
    69  				Vout: []bchain.Vout{
    70  					bchain.Vout{
    71  						N: 0,
    72  						ScriptPubKey: bchain.ScriptPubKey{
    73  							Hex: AddressToPubKeyHex(Addr1, parser),
    74  						},
    75  						ValueSat: *SatB1T1A1,
    76  					},
    77  					bchain.Vout{
    78  						N: 1,
    79  						ScriptPubKey: bchain.ScriptPubKey{
    80  							Hex: AddressToPubKeyHex(Addr2, parser),
    81  						},
    82  						ValueSat: *SatB1T1A2,
    83  					},
    84  				},
    85  				Blocktime:     22549300000,
    86  				Time:          22549300000,
    87  				Confirmations: 2,
    88  			},
    89  			bchain.Tx{
    90  				Txid: TxidB1T2,
    91  				Vout: []bchain.Vout{
    92  					bchain.Vout{
    93  						N: 0,
    94  						ScriptPubKey: bchain.ScriptPubKey{
    95  							Hex: AddressToPubKeyHex(Addr3, parser),
    96  						},
    97  						ValueSat: *SatB1T2A3,
    98  					},
    99  					bchain.Vout{
   100  						N: 1,
   101  						ScriptPubKey: bchain.ScriptPubKey{
   102  							Hex: AddressToPubKeyHex(Addr4, parser),
   103  						},
   104  						ValueSat: *SatB1T2A4,
   105  					},
   106  					bchain.Vout{
   107  						N: 2,
   108  						ScriptPubKey: bchain.ScriptPubKey{
   109  							Hex: AddressToPubKeyHex(Addr5, parser),
   110  						},
   111  						ValueSat: *SatB1T2A5,
   112  					},
   113  				},
   114  				Blocktime:     22549300001,
   115  				Time:          22549300001,
   116  				Confirmations: 2,
   117  			},
   118  		},
   119  	}
   120  }
   121  
   122  func GetTestUTXOBlock2(parser bchain.BlockChainParser) *bchain.Block {
   123  	return &bchain.Block{
   124  		BlockHeader: bchain.BlockHeader{
   125  			Height:        225494,
   126  			Hash:          "00000000eb0443fd7dc4a1ed5c686a8e995057805f9a161d9a5a77a95e72b7b6",
   127  			Size:          2345678,
   128  			Time:          1534859123,
   129  			Confirmations: 1,
   130  		},
   131  		Txs: []bchain.Tx{
   132  			bchain.Tx{
   133  				Txid: TxidB2T1,
   134  				Vin: []bchain.Vin{
   135  					// addr3
   136  					bchain.Vin{
   137  						Txid: TxidB1T2,
   138  						Vout: 0,
   139  					},
   140  					// addr2
   141  					bchain.Vin{
   142  						Txid: TxidB1T1,
   143  						Vout: 1,
   144  					},
   145  				},
   146  				Vout: []bchain.Vout{
   147  					bchain.Vout{
   148  						N: 0,
   149  						ScriptPubKey: bchain.ScriptPubKey{
   150  							Hex: AddressToPubKeyHex(Addr6, parser),
   151  						},
   152  						ValueSat: *SatB2T1A6,
   153  					},
   154  					bchain.Vout{
   155  						N: 1,
   156  						ScriptPubKey: bchain.ScriptPubKey{
   157  							Hex: AddressToPubKeyHex(Addr7, parser),
   158  						},
   159  						ValueSat: *SatB2T1A7,
   160  					},
   161  				},
   162  				Blocktime:     22549400000,
   163  				Time:          22549400000,
   164  				Confirmations: 1,
   165  			},
   166  			bchain.Tx{
   167  				Txid: TxidB2T2,
   168  				Vin: []bchain.Vin{
   169  					// spending an output in the same block - addr6
   170  					bchain.Vin{
   171  						Txid: TxidB2T1,
   172  						Vout: 0,
   173  					},
   174  					// spending an output in the previous block - addr4
   175  					bchain.Vin{
   176  						Txid: TxidB1T2,
   177  						Vout: 1,
   178  					},
   179  				},
   180  				Vout: []bchain.Vout{
   181  					bchain.Vout{
   182  						N: 0,
   183  						ScriptPubKey: bchain.ScriptPubKey{
   184  							Hex: AddressToPubKeyHex(Addr8, parser),
   185  						},
   186  						ValueSat: *SatB2T2A8,
   187  					},
   188  					bchain.Vout{
   189  						N: 1,
   190  						ScriptPubKey: bchain.ScriptPubKey{
   191  							Hex: AddressToPubKeyHex(Addr9, parser),
   192  						},
   193  						ValueSat: *SatB2T2A9,
   194  					},
   195  				},
   196  				Blocktime:     22549400001,
   197  				Time:          22549400001,
   198  				Confirmations: 1,
   199  			},
   200  			// transaction from the same address in the previous block
   201  			bchain.Tx{
   202  				Txid: TxidB2T3,
   203  				Vin: []bchain.Vin{
   204  					// addr5
   205  					bchain.Vin{
   206  						Txid: TxidB1T2,
   207  						Vout: 2,
   208  					},
   209  				},
   210  				Vout: []bchain.Vout{
   211  					bchain.Vout{
   212  						N: 0,
   213  						ScriptPubKey: bchain.ScriptPubKey{
   214  							Hex: AddressToPubKeyHex(Addr5, parser),
   215  						},
   216  						ValueSat: *SatB2T3A5,
   217  					},
   218  				},
   219  				Blocktime:     22549400002,
   220  				Time:          22549400002,
   221  				Confirmations: 1,
   222  			},
   223  			// mining transaction
   224  			bchain.Tx{
   225  				Txid: TxidB2T4,
   226  				Vin: []bchain.Vin{
   227  					bchain.Vin{
   228  						Coinbase: "03bf1e1504aede765b726567696f6e312f50726f6a65637420425443506f6f6c2f01000001bf7e000000000000",
   229  					},
   230  				},
   231  				Vout: []bchain.Vout{
   232  					bchain.Vout{
   233  						N: 0,
   234  						ScriptPubKey: bchain.ScriptPubKey{
   235  							Hex: AddressToPubKeyHex(AddrA, parser),
   236  						},
   237  						ValueSat: *SatB2T4AA,
   238  					},
   239  					bchain.Vout{
   240  						N:            1,
   241  						ScriptPubKey: bchain.ScriptPubKey{},
   242  						ValueSat:     *SatZero,
   243  					},
   244  				},
   245  				Blocktime:     22549400003,
   246  				Time:          22549400003,
   247  				Confirmations: 1,
   248  			},
   249  		},
   250  	}
   251  }