github.com/cryptohub-digital/blockbook@v0.3.5-0.20240403155730-99ab40b9104c/tests/dbtestdata/dbtestdata.go (about)

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