diff --git a/cmd/maintainercli.go b/cmd/maintainercli.go index c6d60975c8..1908869591 100644 --- a/cmd/maintainercli.go +++ b/cmd/maintainercli.go @@ -146,12 +146,13 @@ var listDepositsCommand = cobra.Command{ func printDepositsTable(deposits []*walletmtr.Deposit) error { w := tabwriter.NewWriter(os.Stdout, 2, 4, 1, ' ', tabwriter.AlignRight) - fmt.Fprintf(w, "index\twallet\tvalue (BTC)\tdeposit key\trevealed deposit data\tconfirmations\tswept\t\n") + fmt.Fprintf(w, "index\twallet\ttype\tvalue (BTC)\tdeposit key\trevealed deposit data\tconfirmations\tswept\t\n") for i, deposit := range deposits { - fmt.Fprintf(w, "%d\t%s\t%.5f\t%s\t%s\t%d\t%t\t\n", + fmt.Fprintf(w, "%d\t%s\t%s\t%.5f\t%s\t%s\t%d\t%t\t\n", i, hexutils.Encode(deposit.WalletPublicKeyHash[:]), + deposit.ScriptType, deposit.AmountBtc, deposit.DepositKey, fmt.Sprintf( diff --git a/pkg/bitcoin/script.go b/pkg/bitcoin/script.go index 983381f001..b6bdf144dc 100644 --- a/pkg/bitcoin/script.go +++ b/pkg/bitcoin/script.go @@ -5,6 +5,7 @@ import ( "crypto/elliptic" "crypto/sha256" "fmt" + "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcutil" ) @@ -20,6 +21,21 @@ const ( P2WSHScript ) +func (st ScriptType) String() string { + switch st { + case P2PKHScript: + return "P2PKH" + case P2WPKHScript: + return "P2WPKH" + case P2SHScript: + return "P2SH" + case P2WSHScript: + return "P2WSH" + default: + return "NonStandard" + } +} + // Script represents an arbitrary Bitcoin script, NOT prepended with the // byte-length of the script type Script []byte diff --git a/pkg/maintainer/wallet/deposit_sweep.go b/pkg/maintainer/wallet/deposit_sweep.go index 3a702b1c67..ea4a87d9a2 100644 --- a/pkg/maintainer/wallet/deposit_sweep.go +++ b/pkg/maintainer/wallet/deposit_sweep.go @@ -64,6 +64,7 @@ type Deposit struct { DepositReference WalletPublicKeyHash [20]byte + ScriptType bitcoin.ScriptType DepositKey string IsSwept bool AmountBtc float64 @@ -116,6 +117,19 @@ func FindDeposits( logger.Debugf("getting details of deposit %d/%d", i+1, len(depositRevealedEvents)) + depositTransaction, err := btcChain.GetTransaction( + event.FundingTxHash, + ) + if err != nil { + return result, fmt.Errorf( + "failed to get deposit transaction: [%w]", + err, + ) + } + + publicKeyScript := depositTransaction.Outputs[event.FundingOutputIndex].PublicKeyScript + scriptType := bitcoin.GetScriptType(publicKeyScript) + depositKey := chain.BuildDepositKey(event.FundingTxHash, event.FundingOutputIndex) depositRequest, found, err := chain.GetDepositRequest( @@ -167,6 +181,7 @@ func FindDeposits( RevealBlock: event.BlockNumber, }, WalletPublicKeyHash: event.WalletPublicKeyHash, + ScriptType: scriptType, DepositKey: hexutils.Encode(depositKey.Bytes()), IsSwept: isSwept, AmountBtc: convertSatToBtc(float64(depositRequest.Amount)), diff --git a/pkg/maintainer/wallet/deposit_sweep_test.go b/pkg/maintainer/wallet/deposit_sweep_test.go index ba7ad40e6f..6d32dcb731 100644 --- a/pkg/maintainer/wallet/deposit_sweep_test.go +++ b/pkg/maintainer/wallet/deposit_sweep_test.go @@ -51,6 +51,7 @@ func TestFindDepositsToSweep(t *testing.T) { deposit.FundingOutputIndex, &tbtc.DepositChainRequest{SweptAt: deposit.SweptAt}, ) + btcChain.SetTransaction(deposit.FundingTxHash, deposit.FundingTx) btcChain.SetTransactionConfirmations( deposit.FundingTxHash, deposit.FundingTxConfirmations, diff --git a/pkg/maintainer/wallet/internal/test/marshaling.go b/pkg/maintainer/wallet/internal/test/marshaling.go index 7c0a887587..46e61df931 100644 --- a/pkg/maintainer/wallet/internal/test/marshaling.go +++ b/pkg/maintainer/wallet/internal/test/marshaling.go @@ -1,12 +1,14 @@ package test import ( + "encoding/hex" "encoding/json" "fmt" - walletmtr "github.com/keep-network/keep-core/pkg/maintainer/wallet" "math/big" "time" + walletmtr "github.com/keep-network/keep-core/pkg/maintainer/wallet" + "github.com/keep-network/keep-core/internal/hexutils" "github.com/keep-network/keep-core/pkg/bitcoin" "github.com/keep-network/keep-core/pkg/tbtc" @@ -27,6 +29,7 @@ func (dsts *FindDepositsToSweepTestScenario) UnmarshalJSON(data []byte) error { FundingTxHash string FundingOutputIndex uint32 FundingTxConfirmations uint + FundingTxHex string WalletPublicKeyHash string RevealBlockNumber uint64 SweptAt int64 @@ -39,6 +42,25 @@ func (dsts *FindDepositsToSweepTestScenario) UnmarshalJSON(data []byte) error { } } + bytesFromHex := func(str string) []byte { + value, err := hex.DecodeString(str) + if err != nil { + panic(err) + } + + return value + } + + txFromHex := func(str string) *bitcoin.Transaction { + transaction := new(bitcoin.Transaction) + err := transaction.Deserialize(bytesFromHex(str)) + if err != nil { + panic(err) + } + + return transaction + } + var unmarshaled findDepositsToSweepTestScenario err := json.Unmarshal(data, &unmarshaled) @@ -84,6 +106,7 @@ func (dsts *FindDepositsToSweepTestScenario) UnmarshalJSON(data []byte) error { d.FundingTxHash = fundingTxHash d.FundingOutputIndex = deposit.FundingOutputIndex d.FundingTxConfirmations = deposit.FundingTxConfirmations + d.FundingTx = txFromHex(deposit.FundingTxHex) d.RevealBlockNumber = deposit.RevealBlockNumber d.SweptAt = time.Unix(deposit.SweptAt, 0) diff --git a/pkg/maintainer/wallet/internal/test/testdata/find_deposits_scenario_0.json b/pkg/maintainer/wallet/internal/test/testdata/find_deposits_scenario_0.json index 970fd66cfe..9d03a5674e 100644 --- a/pkg/maintainer/wallet/internal/test/testdata/find_deposits_scenario_0.json +++ b/pkg/maintainer/wallet/internal/test/testdata/find_deposits_scenario_0.json @@ -23,6 +23,7 @@ "FundingTxHash": "dbc6166e149995ef4ed6428d23703756971256ab19954e099fdf2a96fa332251", "FundingOutputIndex": 1, "FundingTxConfirmations": 20, + "FundingTxHex": "02000000000101118b50a9fe2ac54cc581d11f87217cfaacd291f49bb07fc121acf2528f942bb20100000017160014ba88d77b2b41f7de4186d0ea01952ba59ab05d2cfdffffff02ed8f570b0000000017a914e5194b41a0b5105ec1abdbc324045bacde00932b87804f120000000000220020cdbdbc6f38c6218c1ad8fdae8605c42bcfe586fdf48d18136d72dc61eadf3417024730440220622f94dc31bffd12069d6386775d58a8d83b4c52e4223d9c8001bc1751cdec8302203ecee6b8d053c7a583614cbfb1262a80bb353bd486124f8f0356e0281aed85f701210248679793ff33704b185bbb06487f61b32c081ea605fe4a8a33e5271f30c8269100000000", "SweptAt": 102 }, { @@ -31,6 +32,7 @@ "FundingTxHash": "8356227b87fb191d61cff2455cd3f8c33ae208c69a7698b5baf1a331db6d4d8f", "FundingOutputIndex": 2, "FundingTxConfirmations": 34, + "FundingTxHex": "02000000000101798b177a7b8e62494299a5823c389ee88d687d2d2248ad49cdbcec072bbabcef0100000023220020406368b7e3c4861326b216091f3700402a3cce4326c5975f9b5407c7544662bbfdffffff022f1e4b160000000017a914250760145b801de5c7787a35a3d0bd4dae129f7c8740420f0000000000220020663373ae8887c16fb3f0f312f9c0306f2c7b48eb11fade901baa4fa9f7f8b4bb0347304402203accf377fbd65c6cd223147416732b7c32c5502f081372dfcfb085937eac68790220106bd48535db08ed325b12e59006300a5f7d45efc0fb5e0ba9bd052eb9db6ec20147304402200bffe4bc7a743f2f9c9745b81f7303f9c86a57df04fa04b34adb7cf3dc630c5702206aded842db1b8a710d8113d5317d12b7a20fc2dd9ddfd0537dab8fd26bae2a19014e210288e71799f2480443b10147d37e4f41976b6c2c220ea89e5053ed2a58333a9687ad210211fc7914551272419d73ec2e873050afa3f37732fd4fc891d211149d66bf1ac6ac73640380ca00b268cce52400", "SweptAt": 0 }, { @@ -39,6 +41,7 @@ "FundingTxHash": "d91868ca43db4deb96047d727a5e782f282864fde2d9364f8c562c8998ba64bf", "FundingOutputIndex": 1, "FundingTxConfirmations": 6, + "FundingTxHex": "0200000000010180c16723b30e6bd2ed340b1d5c9c581765591daed800e16b7970c160aba89b1600000000232200204c469cd67de0cfde55e8067570178dc1935a8387f8b4005b5127918fb08da636fdffffff02854571160000000017a914e26de2c3f4ebaedabe94ca3f5374edcb5c2010af8793ec1700000000002200205fc0c323555ad54bfbc0f2d88429fb660208248b2711e22c3dde3f340e5a94e4034730440220694178395f9c4b1b2a7ebd450797d2aa23ec1082c4b7a8ccab018e675d64c71f02200a5cf90497c16b2888ae48087d59bf52e3501ea7229d77db47d8d761a006804b014730440220550ed7a454a8f7c26dcdb5ff887a21baa7f4c9de140eda0ee8e83760e839f29e02200902c3ed2fc1acb0c10f28289914ca9d027dfcdbf3469e3594e7c1b421e26642014e2103e749c7066765961417a5f714e6bc3075b9c517f4743e211d308a5d1bbd39c531ad21025a7941db7bf0f6345125470e7bf70fff8ad78bd5d1ac26b689ae554351afa14cac73640380ca00b2686be52400", "SweptAt": 0 }, { @@ -47,6 +50,7 @@ "FundingTxHash": "22703dae51de3c45ded183a39a345c101e108df32d50a1d9282e95dee67b9cfd", "FundingOutputIndex": 0, "FundingTxConfirmations": 5, + "FundingTxHex": "0200000000010236e005bedbfe340d73f282debf5f28b436b72ed06d9b8b1d3b71da6992158d810100000023220020e33c1bef27da93c100a0626a9dff06059d088b091b038f3b54510e3667fe5775fdffffff0e426895ab4c5b9aa09e063366d5f7668ed912d4d99809d70ac24faeb65bd6a6000000002322002064d1e5adca22a6bf68b4db5d11d6cd0eeabca62efbcfa7346be57a1cf3b4b6affdffffff0240420f000000000022002058e34e684a5d823c40f069fb2235f156741c3e7c675a47fdcacf5718d517763aa4cee0050000000017a914e759f47b61cae21f9478aaae06395f8a7dce22aa8703473044022028d3104e19a40717f854c16a31fc41224abedf6fed87996dacf193561193b5a002204e80434e6609c4b0c8112c2603e717c98b75f676de9c40c628d210d9bf28ed3a014730440220774d6049dec6c3962fed40b6074b6757c5979ebfe9bafe3c6150e17adbbef4c70220672fc08eb4cfeafa021ab15119d46a95ce4ce607d1f65dd53e9ded0e53216012014e2103b4487135c395b553e0b344073dcc0005f49212fe5fc9c42761d24e0cc49caf90ad210358d8e8275e8e038194c4f508d41debfe8e87303427222e37c73254c2a329d809ac73640380ca00b2680347304402205ffa05c267dc891ab5012516ce13f7f3021e7826c8e4c5ae57cedf5cea0283c902202444822c9f43cc977154560553ba74166d1b5de9622f4481afd92b9f70e84cc8014730440220593a13011104596c57bdb9794d169ff7950884baadf51d34b42ecb84f5104bb602203b5d49897ac2cdb8f25afbc4cd18b99f788a8f19f009e4edc97a76c40f3a9173014e21030ad8a268049e4010b52c4debb7afa36260c8641f96527b5e18b23c7ad702f42cad210236e934c5ab487b83678cfbc0b3c07fbdac5dec5beb8ddcf959d7a5528ba8a999ac73640380ca00b26838e62400", "SweptAt": 0 }, { @@ -55,6 +59,7 @@ "FundingTxHash": "c693aaa540d22bd7cf70c17cb71c1d789ea68138d87fdb6ea70e450effeb2137", "FundingOutputIndex": 0, "FundingTxConfirmations": 23, + "FundingTxHex": "02000000000101c117bb133822c228ef9d7e814b734bbd8cf9a39be1a78811783ce122b1671c800100000017160014244284695f02a38fe01f8562c5fd4cf5e35a7c0afdffffff0280f0fa020000000022002070fd0969b60dae8f9ab0a18e878b5f1493f5da29abc2d5cbb2ce3ff5769f002617932b7d0000000017a9141857151c899fc7cb9290272f55779b6b2784dd5f870247304402202b4dd178d08945fd2d2a9f02b91878bbdcaa4e9b26f94258253c3f9eddf1346c0220454a6b702d9d54fd3db42e13815f4de93a4278be2ba3cc56ba92a37207999c63012103a5c18433b42ec348c06cf8355d6298f63a02d0b226276685df400098ddffc73a00000000", "SweptAt": 108 }, { @@ -63,14 +68,16 @@ "FundingTxHash": "a8c3b3c1975094550d481bdffdee1b7b7613dd74dbce37a5f6dce7fd9ac0ace1", "FundingOutputIndex": 1, "FundingTxConfirmations": 25, + "FundingTxHex": "0200000001f27efeb4afb32e78d603d0b769843ed007259f0027d5185fbad063ccd82c235c010000006a47304402207c020003bff841c017163666b9fbe9e1c143d0c410c90bf888185c827c1a6a740220440382a53cd6d58e3ff27c12dcfcfb280e3518c916b3e39c1369556218cfb8c3012103da66b07988ccaeecd41281fff3cd20151d3a8876affaa1030dfba4c2d5480df4fdffffff02c0460800000000001976a91486c61f2297dea5da22dcf8c044809030c0239d9188ac804f1200000000002200203f5a823861085e75d21c5574495e60095f3d62e90b8258c601f9f67fe9ea5e703ef32400", "SweptAt": 0 }, { "RevealBlockNumber": 22, "WalletPublicKeyHash": "0x7670343fc00ccc2d0cd65360e6ad400697ea0fed", "FundingTxHash": "178628f0fd77ca04a31e771805277405288404da38eb86a0e369f2b26d45fe97", - "FundingOutputIndex": 4, + "FundingOutputIndex": 0, "FundingTxConfirmations": 34, + "FundingTxHex": "02000000000101927dcff5fa228252124c24e4746141fe0db9fc41f4712d449fad9f33fe3fa3780000000023220020481719bc4e385205ed350423b31ecd15519897a40abd9996ffd4abe31dd57cb9fdffffff02e5a939080000000017a914239b741cd84ba7eadc838839288f1cfbbb218a248740420f00000000002200200c273a194459d101f66ed8fd231b4188726e1b86b7bd80cde376231779522d540347304402201f8befe88ee75d96a05b27635f5a6f178f79e33efd8323e948c43c7f8d84bf7802205e7c642b1dfbb0e584c823e375294520b800d8cd76f6ee717cb8044f9156b19801473044022005373bbe8fc4fa09fc918cb75c20fa69ece69ba5377c80c89fd08781d2d2ecf20220071e1cdd5a8b6cfcba9118755bcaac923d94a967887c9ffbc5653559fab73877014e21039974c5b0c669201c6e3e4715089c710291d208c584e1fe77ae44a9d81f065371ad21021df7f70250ff11cda7363b91f6c4615b4063c43331ab1b0d61d7e2763833efebac73640380ca00b268b6e62400", "SweptAt": 109 }, { @@ -79,14 +86,16 @@ "FundingTxHash": "a3d1781b59d5e8680772a8bb7f897c4ff0459d3465d7fa678f80a4f0ec900574", "FundingOutputIndex": 0, "FundingTxConfirmations": 23, + "FundingTxHex": "02000000000101bd9f07edd2fda4285517aab17a9789b9bda1c952fb5dd9364b64f772be8bb29f0100000000fdffffff02ef29bc6a000000001600144e67d6d5e0fed4f124525b61a592254f7f6c927740420f00000000002200200fde29196d14069a5cf048da936c49451b84c9f32934dc3589778da0acbd881702473044022066d0e785227afe107dc1eb851901fa0d92cc97db0b8fc281185396f86d4e636502200efdff22980ade7d6edc6d4436ece536086b19122267061d95db758b415811ff01210270220cbc33ed153b0059060254665cfe81e0f661568d0a73c5660a287db4b94b00000000", "SweptAt": 0 }, { "RevealBlockNumber": 32, "WalletPublicKeyHash": "0x03b74d6893ad46dfdd01b9e0e3b3385f4fce2d1e", "FundingTxHash": "b822b302dab7c1fcc3292782635be133538a0f803468a2d847023c24f867f479", - "FundingOutputIndex": 3, + "FundingOutputIndex": 1, "FundingTxConfirmations": 25, + "FundingTxHex": "02000000000101d9eae6dedef56edcc4c884a84f4127c92a18f1674562960ed7770656165d32b101000000232200209fd1e4519124fe6655ba29f9690fc00a03a3d3b491db3b7f710614b8d8024d8dfdffffff0240420f0000000000220020e99a81c3fa4e98410937231296f33538b03c614c1eb8de6a51f03e1b404d0b19ccb566050000000017a9146323da8694056713624b4818d4ccc2433dd7971d8703473044022063ff0a0bbee811b393f7badc091bffc913c7dbc921a3bbcd4c5c873a946f353b022074c128f86c7a4b826ece9b15c612cacbd2ab064c9b4bf27671f545069b803f750147304402200d1d56c74355d68d6a3f59b3366ed3e3254da16e045b44bd1ac6e64059c7439c0220741c03eeffb437d6849730e9eef9c063b0e74dd3fdac54c06853992c0718bea5014e2103897c250217abd55d3a332788f08b7682a44137b5c9d4f882f985059d9c1c3821ad21034ced46df0f98b8cbf2aa8803cffd60a5b475f0745d0f7d9369aa88e122f9a313ac73640380ca00b268df132500", "SweptAt": 0 } ], @@ -105,7 +114,7 @@ { "RevealBlockNumber": 32, "FundingTxHash": "b822b302dab7c1fcc3292782635be133538a0f803468a2d847023c24f867f479", - "FundingOutputIndex": 3 + "FundingOutputIndex": 1 } ] } diff --git a/pkg/maintainer/wallet/internal/test/testdata/find_deposits_scenario_1.json b/pkg/maintainer/wallet/internal/test/testdata/find_deposits_scenario_1.json index 5b6dadc45f..4ed79ef5aa 100644 --- a/pkg/maintainer/wallet/internal/test/testdata/find_deposits_scenario_1.json +++ b/pkg/maintainer/wallet/internal/test/testdata/find_deposits_scenario_1.json @@ -23,6 +23,7 @@ "FundingTxHash": "dbc6166e149995ef4ed6428d23703756971256ab19954e099fdf2a96fa332251", "FundingOutputIndex": 1, "FundingTxConfirmations": 20, + "FundingTxHex": "02000000000101118b50a9fe2ac54cc581d11f87217cfaacd291f49bb07fc121acf2528f942bb20100000017160014ba88d77b2b41f7de4186d0ea01952ba59ab05d2cfdffffff02ed8f570b0000000017a914e5194b41a0b5105ec1abdbc324045bacde00932b87804f120000000000220020cdbdbc6f38c6218c1ad8fdae8605c42bcfe586fdf48d18136d72dc61eadf3417024730440220622f94dc31bffd12069d6386775d58a8d83b4c52e4223d9c8001bc1751cdec8302203ecee6b8d053c7a583614cbfb1262a80bb353bd486124f8f0356e0281aed85f701210248679793ff33704b185bbb06487f61b32c081ea605fe4a8a33e5271f30c8269100000000", "SweptAt": 102 }, { @@ -31,6 +32,7 @@ "FundingTxHash": "d91868ca43db4deb96047d727a5e782f282864fde2d9364f8c562c8998ba64bf", "FundingOutputIndex": 1, "FundingTxConfirmations": 20, + "FundingTxHex": "0200000000010180c16723b30e6bd2ed340b1d5c9c581765591daed800e16b7970c160aba89b1600000000232200204c469cd67de0cfde55e8067570178dc1935a8387f8b4005b5127918fb08da636fdffffff02854571160000000017a914e26de2c3f4ebaedabe94ca3f5374edcb5c2010af8793ec1700000000002200205fc0c323555ad54bfbc0f2d88429fb660208248b2711e22c3dde3f340e5a94e4034730440220694178395f9c4b1b2a7ebd450797d2aa23ec1082c4b7a8ccab018e675d64c71f02200a5cf90497c16b2888ae48087d59bf52e3501ea7229d77db47d8d761a006804b014730440220550ed7a454a8f7c26dcdb5ff887a21baa7f4c9de140eda0ee8e83760e839f29e02200902c3ed2fc1acb0c10f28289914ca9d027dfcdbf3469e3594e7c1b421e26642014e2103e749c7066765961417a5f714e6bc3075b9c517f4743e211d308a5d1bbd39c531ad21025a7941db7bf0f6345125470e7bf70fff8ad78bd5d1ac26b689ae554351afa14cac73640380ca00b2686be52400", "SweptAt": 0 }, { @@ -39,6 +41,7 @@ "FundingTxHash": "c693aaa540d22bd7cf70c17cb71c1d789ea68138d87fdb6ea70e450effeb2137", "FundingOutputIndex": 0, "FundingTxConfirmations": 23, + "FundingTxHex": "02000000000101c117bb133822c228ef9d7e814b734bbd8cf9a39be1a78811783ce122b1671c800100000017160014244284695f02a38fe01f8562c5fd4cf5e35a7c0afdffffff0280f0fa020000000022002070fd0969b60dae8f9ab0a18e878b5f1493f5da29abc2d5cbb2ce3ff5769f002617932b7d0000000017a9141857151c899fc7cb9290272f55779b6b2784dd5f870247304402202b4dd178d08945fd2d2a9f02b91878bbdcaa4e9b26f94258253c3f9eddf1346c0220454a6b702d9d54fd3db42e13815f4de93a4278be2ba3cc56ba92a37207999c63012103a5c18433b42ec348c06cf8355d6298f63a02d0b226276685df400098ddffc73a00000000", "SweptAt": 108 }, { @@ -47,14 +50,16 @@ "FundingTxHash": "a8c3b3c1975094550d481bdffdee1b7b7613dd74dbce37a5f6dce7fd9ac0ace1", "FundingOutputIndex": 1, "FundingTxConfirmations": 25, + "FundingTxHex": "0200000001f27efeb4afb32e78d603d0b769843ed007259f0027d5185fbad063ccd82c235c010000006a47304402207c020003bff841c017163666b9fbe9e1c143d0c410c90bf888185c827c1a6a740220440382a53cd6d58e3ff27c12dcfcfb280e3518c916b3e39c1369556218cfb8c3012103da66b07988ccaeecd41281fff3cd20151d3a8876affaa1030dfba4c2d5480df4fdffffff02c0460800000000001976a91486c61f2297dea5da22dcf8c044809030c0239d9188ac804f1200000000002200203f5a823861085e75d21c5574495e60095f3d62e90b8258c601f9f67fe9ea5e703ef32400", "SweptAt": 0 }, { "RevealBlockNumber": 22, "WalletPublicKeyHash": "0x7670343fc00ccc2d0cd65360e6ad400697ea0fed", "FundingTxHash": "178628f0fd77ca04a31e771805277405288404da38eb86a0e369f2b26d45fe97", - "FundingOutputIndex": 4, + "FundingOutputIndex": 1, "FundingTxConfirmations": 34, + "FundingTxHex": "02000000000101927dcff5fa228252124c24e4746141fe0db9fc41f4712d449fad9f33fe3fa3780000000023220020481719bc4e385205ed350423b31ecd15519897a40abd9996ffd4abe31dd57cb9fdffffff02e5a939080000000017a914239b741cd84ba7eadc838839288f1cfbbb218a248740420f00000000002200200c273a194459d101f66ed8fd231b4188726e1b86b7bd80cde376231779522d540347304402201f8befe88ee75d96a05b27635f5a6f178f79e33efd8323e948c43c7f8d84bf7802205e7c642b1dfbb0e584c823e375294520b800d8cd76f6ee717cb8044f9156b19801473044022005373bbe8fc4fa09fc918cb75c20fa69ece69ba5377c80c89fd08781d2d2ecf20220071e1cdd5a8b6cfcba9118755bcaac923d94a967887c9ffbc5653559fab73877014e21039974c5b0c669201c6e3e4715089c710291d208c584e1fe77ae44a9d81f065371ad21021df7f70250ff11cda7363b91f6c4615b4063c43331ab1b0d61d7e2763833efebac73640380ca00b268b6e62400", "SweptAt": 109 }, { @@ -63,6 +68,7 @@ "FundingTxHash": "a3d1781b59d5e8680772a8bb7f897c4ff0459d3465d7fa678f80a4f0ec900574", "FundingOutputIndex": 0, "FundingTxConfirmations": 23, + "FundingTxHex": "02000000000101bd9f07edd2fda4285517aab17a9789b9bda1c952fb5dd9364b64f772be8bb29f0100000000fdffffff02ef29bc6a000000001600144e67d6d5e0fed4f124525b61a592254f7f6c927740420f00000000002200200fde29196d14069a5cf048da936c49451b84c9f32934dc3589778da0acbd881702473044022066d0e785227afe107dc1eb851901fa0d92cc97db0b8fc281185396f86d4e636502200efdff22980ade7d6edc6d4436ece536086b19122267061d95db758b415811ff01210270220cbc33ed153b0059060254665cfe81e0f661568d0a73c5660a287db4b94b00000000", "SweptAt": 0 }, { @@ -71,6 +77,7 @@ "FundingTxHash": "b822b302dab7c1fcc3292782635be133538a0f803468a2d847023c24f867f479", "FundingOutputIndex": 3, "FundingTxConfirmations": 25, + "FundingTxHex": "02000000000101d9eae6dedef56edcc4c884a84f4127c92a18f1674562960ed7770656165d32b101000000232200209fd1e4519124fe6655ba29f9690fc00a03a3d3b491db3b7f710614b8d8024d8dfdffffff0240420f0000000000220020e99a81c3fa4e98410937231296f33538b03c614c1eb8de6a51f03e1b404d0b19ccb566050000000017a9146323da8694056713624b4818d4ccc2433dd7971d8703473044022063ff0a0bbee811b393f7badc091bffc913c7dbc921a3bbcd4c5c873a946f353b022074c128f86c7a4b826ece9b15c612cacbd2ab064c9b4bf27671f545069b803f750147304402200d1d56c74355d68d6a3f59b3366ed3e3254da16e045b44bd1ac6e64059c7439c0220741c03eeffb437d6849730e9eef9c063b0e74dd3fdac54c06853992c0718bea5014e2103897c250217abd55d3a332788f08b7682a44137b5c9d4f882f985059d9c1c3821ad21034ced46df0f98b8cbf2aa8803cffd60a5b475f0745d0f7d9369aa88e122f9a313ac73640380ca00b268df132500", "SweptAt": 0 } ], diff --git a/pkg/maintainer/wallet/internal/test/testdata/find_deposits_scenario_2.json b/pkg/maintainer/wallet/internal/test/testdata/find_deposits_scenario_2.json index 076d892e72..7ae143fffc 100644 --- a/pkg/maintainer/wallet/internal/test/testdata/find_deposits_scenario_2.json +++ b/pkg/maintainer/wallet/internal/test/testdata/find_deposits_scenario_2.json @@ -23,6 +23,7 @@ "FundingTxHash": "dbc6166e149995ef4ed6428d23703756971256ab19954e099fdf2a96fa332251", "FundingOutputIndex": 1, "FundingTxConfirmations": 20, + "FundingTxHex": "02000000000101118b50a9fe2ac54cc581d11f87217cfaacd291f49bb07fc121acf2528f942bb20100000017160014ba88d77b2b41f7de4186d0ea01952ba59ab05d2cfdffffff02ed8f570b0000000017a914e5194b41a0b5105ec1abdbc324045bacde00932b87804f120000000000220020cdbdbc6f38c6218c1ad8fdae8605c42bcfe586fdf48d18136d72dc61eadf3417024730440220622f94dc31bffd12069d6386775d58a8d83b4c52e4223d9c8001bc1751cdec8302203ecee6b8d053c7a583614cbfb1262a80bb353bd486124f8f0356e0281aed85f701210248679793ff33704b185bbb06487f61b32c081ea605fe4a8a33e5271f30c8269100000000", "SweptAt": 102 }, { @@ -31,6 +32,7 @@ "FundingTxHash": "d91868ca43db4deb96047d727a5e782f282864fde2d9364f8c562c8998ba64bf", "FundingOutputIndex": 1, "FundingTxConfirmations": 20, + "FundingTxHex": "0200000000010180c16723b30e6bd2ed340b1d5c9c581765591daed800e16b7970c160aba89b1600000000232200204c469cd67de0cfde55e8067570178dc1935a8387f8b4005b5127918fb08da636fdffffff02854571160000000017a914e26de2c3f4ebaedabe94ca3f5374edcb5c2010af8793ec1700000000002200205fc0c323555ad54bfbc0f2d88429fb660208248b2711e22c3dde3f340e5a94e4034730440220694178395f9c4b1b2a7ebd450797d2aa23ec1082c4b7a8ccab018e675d64c71f02200a5cf90497c16b2888ae48087d59bf52e3501ea7229d77db47d8d761a006804b014730440220550ed7a454a8f7c26dcdb5ff887a21baa7f4c9de140eda0ee8e83760e839f29e02200902c3ed2fc1acb0c10f28289914ca9d027dfcdbf3469e3594e7c1b421e26642014e2103e749c7066765961417a5f714e6bc3075b9c517f4743e211d308a5d1bbd39c531ad21025a7941db7bf0f6345125470e7bf70fff8ad78bd5d1ac26b689ae554351afa14cac73640380ca00b2686be52400", "SweptAt": 0 }, { @@ -39,6 +41,7 @@ "FundingTxHash": "c693aaa540d22bd7cf70c17cb71c1d789ea68138d87fdb6ea70e450effeb2137", "FundingOutputIndex": 0, "FundingTxConfirmations": 23, + "FundingTxHex": "02000000000101c117bb133822c228ef9d7e814b734bbd8cf9a39be1a78811783ce122b1671c800100000017160014244284695f02a38fe01f8562c5fd4cf5e35a7c0afdffffff0280f0fa020000000022002070fd0969b60dae8f9ab0a18e878b5f1493f5da29abc2d5cbb2ce3ff5769f002617932b7d0000000017a9141857151c899fc7cb9290272f55779b6b2784dd5f870247304402202b4dd178d08945fd2d2a9f02b91878bbdcaa4e9b26f94258253c3f9eddf1346c0220454a6b702d9d54fd3db42e13815f4de93a4278be2ba3cc56ba92a37207999c63012103a5c18433b42ec348c06cf8355d6298f63a02d0b226276685df400098ddffc73a00000000", "SweptAt": 108 }, { @@ -47,6 +50,7 @@ "FundingTxHash": "a8c3b3c1975094550d481bdffdee1b7b7613dd74dbce37a5f6dce7fd9ac0ace1", "FundingOutputIndex": 1, "FundingTxConfirmations": 25, + "FundingTxHex": "0200000001f27efeb4afb32e78d603d0b769843ed007259f0027d5185fbad063ccd82c235c010000006a47304402207c020003bff841c017163666b9fbe9e1c143d0c410c90bf888185c827c1a6a740220440382a53cd6d58e3ff27c12dcfcfb280e3518c916b3e39c1369556218cfb8c3012103da66b07988ccaeecd41281fff3cd20151d3a8876affaa1030dfba4c2d5480df4fdffffff02c0460800000000001976a91486c61f2297dea5da22dcf8c044809030c0239d9188ac804f1200000000002200203f5a823861085e75d21c5574495e60095f3d62e90b8258c601f9f67fe9ea5e703ef32400", "SweptAt": 0 }, { @@ -55,6 +59,7 @@ "FundingTxHash": "178628f0fd77ca04a31e771805277405288404da38eb86a0e369f2b26d45fe97", "FundingOutputIndex": 4, "FundingTxConfirmations": 34, + "FundingTxHex": "02000000000101927dcff5fa228252124c24e4746141fe0db9fc41f4712d449fad9f33fe3fa3780000000023220020481719bc4e385205ed350423b31ecd15519897a40abd9996ffd4abe31dd57cb9fdffffff02e5a939080000000017a914239b741cd84ba7eadc838839288f1cfbbb218a248740420f00000000002200200c273a194459d101f66ed8fd231b4188726e1b86b7bd80cde376231779522d540347304402201f8befe88ee75d96a05b27635f5a6f178f79e33efd8323e948c43c7f8d84bf7802205e7c642b1dfbb0e584c823e375294520b800d8cd76f6ee717cb8044f9156b19801473044022005373bbe8fc4fa09fc918cb75c20fa69ece69ba5377c80c89fd08781d2d2ecf20220071e1cdd5a8b6cfcba9118755bcaac923d94a967887c9ffbc5653559fab73877014e21039974c5b0c669201c6e3e4715089c710291d208c584e1fe77ae44a9d81f065371ad21021df7f70250ff11cda7363b91f6c4615b4063c43331ab1b0d61d7e2763833efebac73640380ca00b268b6e62400", "SweptAt": 109 }, { @@ -63,6 +68,7 @@ "FundingTxHash": "a3d1781b59d5e8680772a8bb7f897c4ff0459d3465d7fa678f80a4f0ec900574", "FundingOutputIndex": 0, "FundingTxConfirmations": 23, + "FundingTxHex": "02000000000101bd9f07edd2fda4285517aab17a9789b9bda1c952fb5dd9364b64f772be8bb29f0100000000fdffffff02ef29bc6a000000001600144e67d6d5e0fed4f124525b61a592254f7f6c927740420f00000000002200200fde29196d14069a5cf048da936c49451b84c9f32934dc3589778da0acbd881702473044022066d0e785227afe107dc1eb851901fa0d92cc97db0b8fc281185396f86d4e636502200efdff22980ade7d6edc6d4436ece536086b19122267061d95db758b415811ff01210270220cbc33ed153b0059060254665cfe81e0f661568d0a73c5660a287db4b94b00000000", "SweptAt": 0 }, { @@ -71,6 +77,7 @@ "FundingTxHash": "b822b302dab7c1fcc3292782635be133538a0f803468a2d847023c24f867f479", "FundingOutputIndex": 3, "FundingTxConfirmations": 25, + "FundingTxHex": "02000000000101d9eae6dedef56edcc4c884a84f4127c92a18f1674562960ed7770656165d32b101000000232200209fd1e4519124fe6655ba29f9690fc00a03a3d3b491db3b7f710614b8d8024d8dfdffffff0240420f0000000000220020e99a81c3fa4e98410937231296f33538b03c614c1eb8de6a51f03e1b404d0b19ccb566050000000017a9146323da8694056713624b4818d4ccc2433dd7971d8703473044022063ff0a0bbee811b393f7badc091bffc913c7dbc921a3bbcd4c5c873a946f353b022074c128f86c7a4b826ece9b15c612cacbd2ab064c9b4bf27671f545069b803f750147304402200d1d56c74355d68d6a3f59b3366ed3e3254da16e045b44bd1ac6e64059c7439c0220741c03eeffb437d6849730e9eef9c063b0e74dd3fdac54c06853992c0718bea5014e2103897c250217abd55d3a332788f08b7682a44137b5c9d4f882f985059d9c1c3821ad21034ced46df0f98b8cbf2aa8803cffd60a5b475f0745d0f7d9369aa88e122f9a313ac73640380ca00b268df132500", "SweptAt": 0 } ], diff --git a/pkg/maintainer/wallet/internal/test/testdata/find_deposits_scenario_3.json b/pkg/maintainer/wallet/internal/test/testdata/find_deposits_scenario_3.json index f57b671d3d..c0dc1b480f 100644 --- a/pkg/maintainer/wallet/internal/test/testdata/find_deposits_scenario_3.json +++ b/pkg/maintainer/wallet/internal/test/testdata/find_deposits_scenario_3.json @@ -15,14 +15,16 @@ "FundingTxHash": "dbc6166e149995ef4ed6428d23703756971256ab19954e099fdf2a96fa332251", "FundingOutputIndex": 1, "FundingTxConfirmations": 20, + "FundingTxHex": "02000000000101118b50a9fe2ac54cc581d11f87217cfaacd291f49bb07fc121acf2528f942bb20100000017160014ba88d77b2b41f7de4186d0ea01952ba59ab05d2cfdffffff02ed8f570b0000000017a914e5194b41a0b5105ec1abdbc324045bacde00932b87804f120000000000220020cdbdbc6f38c6218c1ad8fdae8605c42bcfe586fdf48d18136d72dc61eadf3417024730440220622f94dc31bffd12069d6386775d58a8d83b4c52e4223d9c8001bc1751cdec8302203ecee6b8d053c7a583614cbfb1262a80bb353bd486124f8f0356e0281aed85f701210248679793ff33704b185bbb06487f61b32c081ea605fe4a8a33e5271f30c8269100000000", "SweptAt": 102 }, { "RevealBlockNumber": 7, "WalletPublicKeyHash": "0x928d992e5f5b71de51a1b40fcc4056b99a88a647", "FundingTxHash": "8356227b87fb191d61cff2455cd3f8c33ae208c69a7698b5baf1a331db6d4d8f", - "FundingOutputIndex": 2, + "FundingOutputIndex": 1, "FundingTxConfirmations": 34, + "FundingTxHex": "02000000000101798b177a7b8e62494299a5823c389ee88d687d2d2248ad49cdbcec072bbabcef0100000023220020406368b7e3c4861326b216091f3700402a3cce4326c5975f9b5407c7544662bbfdffffff022f1e4b160000000017a914250760145b801de5c7787a35a3d0bd4dae129f7c8740420f0000000000220020663373ae8887c16fb3f0f312f9c0306f2c7b48eb11fade901baa4fa9f7f8b4bb0347304402203accf377fbd65c6cd223147416732b7c32c5502f081372dfcfb085937eac68790220106bd48535db08ed325b12e59006300a5f7d45efc0fb5e0ba9bd052eb9db6ec20147304402200bffe4bc7a743f2f9c9745b81f7303f9c86a57df04fa04b34adb7cf3dc630c5702206aded842db1b8a710d8113d5317d12b7a20fc2dd9ddfd0537dab8fd26bae2a19014e210288e71799f2480443b10147d37e4f41976b6c2c220ea89e5053ed2a58333a9687ad210211fc7914551272419d73ec2e873050afa3f37732fd4fc891d211149d66bf1ac6ac73640380ca00b268cce52400", "SweptAt": 0 } ], @@ -31,7 +33,7 @@ { "RevealBlockNumber": 7, "FundingTxHash": "8356227b87fb191d61cff2455cd3f8c33ae208c69a7698b5baf1a331db6d4d8f", - "FundingOutputIndex": 2 + "FundingOutputIndex": 1 } ] } diff --git a/pkg/maintainer/wallet/internal/test/wallettest.go b/pkg/maintainer/wallet/internal/test/wallettest.go index dbecee8295..8d3a478d3a 100644 --- a/pkg/maintainer/wallet/internal/test/wallettest.go +++ b/pkg/maintainer/wallet/internal/test/wallettest.go @@ -3,7 +3,6 @@ package test import ( "encoding/json" "fmt" - walletmtr "github.com/keep-network/keep-core/pkg/maintainer/wallet" "io/fs" "io/ioutil" "path/filepath" @@ -11,6 +10,8 @@ import ( "strings" "time" + walletmtr "github.com/keep-network/keep-core/pkg/maintainer/wallet" + "github.com/keep-network/keep-core/pkg/bitcoin" "github.com/keep-network/keep-core/pkg/tbtc" ) @@ -33,6 +34,7 @@ type Deposit struct { FundingTxHash bitcoin.Hash FundingOutputIndex uint32 FundingTxConfirmations uint + FundingTx *bitcoin.Transaction WalletPublicKeyHash [20]byte