github.com/grupokindynos/coins-explorer@v0.0.0-20210507172551-fa8983d19250/tests/dbtestdata/dbtestdata.go (about)

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