diff --git a/.dockerignore b/.dockerignore index 6c0434c094..e46b29ee0f 100644 --- a/.dockerignore +++ b/.dockerignore @@ -33,6 +33,9 @@ token-tracker/ !**/gen/cmd/cmd.go !pkg/chain/ethereum/frost/gen/abi/*.go !pkg/chain/ethereum/frost/gen/validatorabi/*.go +!pkg/chain/ethereum/tbtc/gen/abi/*.go +!pkg/chain/ethereum/tbtc/gen/contract/*.go +!pkg/chain/ethereum/tbtc/gen/cmd/*.go # Legacy V1 contracts bindings. # We won't generate new bindings in the docker build process, but use the existing ones. diff --git a/cmd/flags.go b/cmd/flags.go index 9e2c43d533..289e5742b3 100644 --- a/cmd/flags.go +++ b/cmd/flags.go @@ -317,6 +317,20 @@ func initTbtcFlags(cmd *cobra.Command, cfg *config.Config) { "`native` allows transitional legacy fallback; `ffi` requires native execution. "+ "Empty value selects legacy.", ) + + cmd.Flags().BoolVar( + &cfg.Tbtc.DisableLegacyECDSA, + "tbtc.disableLegacyECDSA", + false, + "Disable legacy ECDSA wallet DKG and pre-params generation for FROST-only deployments.", + ) + + cmd.Flags().BoolVar( + &cfg.Tbtc.DisableLegacySortitionPoolMonitoring, + "tbtc.disableLegacySortitionPoolMonitoring", + false, + "Disable legacy ECDSA sortition pool monitoring for FROST-only deployments.", + ) } // Initialize flags for Maintainer configuration. diff --git a/cmd/flags_test.go b/cmd/flags_test.go index cee7fd2ed8..a59b65555c 100644 --- a/cmd/flags_test.go +++ b/cmd/flags_test.go @@ -232,6 +232,24 @@ var cmdFlagsTests = map[string]struct { expectedValueFromFlag: "native", defaultValue: "", }, + "tbtc.disableLegacyECDSA": { + readValueFunc: func(c *config.Config) interface{} { + return c.Tbtc.DisableLegacyECDSA + }, + flagName: "--tbtc.disableLegacyECDSA", + flagValue: "", // don't provide any value + expectedValueFromFlag: true, + defaultValue: false, + }, + "tbtc.disableLegacySortitionPoolMonitoring": { + readValueFunc: func(c *config.Config) interface{} { + return c.Tbtc.DisableLegacySortitionPoolMonitoring + }, + flagName: "--tbtc.disableLegacySortitionPoolMonitoring", + flagValue: "", // don't provide any value + expectedValueFromFlag: true, + defaultValue: false, + }, "maintainer.bitcoinDifficulty": { readValueFunc: func(c *config.Config) interface{} { return c.Maintainer.BitcoinDifficulty.Enabled }, flagName: "--bitcoinDifficulty", diff --git a/pkg/bitcoin/electrum/electrum.go b/pkg/bitcoin/electrum/electrum.go index 70cbc82309..f94fe471ef 100644 --- a/pkg/bitcoin/electrum/electrum.go +++ b/pkg/bitcoin/electrum/electrum.go @@ -434,6 +434,56 @@ func (c *Connection) GetTransactionsForPublicKeyHash( return transactions, nil } +// GetTransactionsForPublicKeyScripts gets confirmed transactions that pay to +// any of the given public key scripts. The returned transactions are ordered +// by block height in ascending order, i.e. the latest transaction is at the +// end of the list. +func (c *Connection) GetTransactionsForPublicKeyScripts( + publicKeyScripts []bitcoin.Script, + limit int, +) ([]*bitcoin.Transaction, error) { + txHashes, err := c.GetTxHashesForPublicKeyScripts(publicKeyScripts) + if err != nil { + return nil, err + } + + selectedTxHashes := selectLatestUniqueTxHashes(txHashes, limit) + + transactions := make([]*bitcoin.Transaction, len(selectedTxHashes)) + for i, txHash := range selectedTxHashes { + transaction, err := c.GetTransaction(txHash) + if err != nil { + return nil, fmt.Errorf("cannot get transaction: [%v]", err) + } + + transactions[i] = transaction + } + + return transactions, nil +} + +func selectLatestUniqueTxHashes( + txHashes []bitcoin.Hash, + limit int, +) []bitcoin.Hash { + uniqueTxHashes := make([]bitcoin.Hash, 0, len(txHashes)) + seen := make(map[bitcoin.Hash]bool) + for _, txHash := range txHashes { + if seen[txHash] { + continue + } + + seen[txHash] = true + uniqueTxHashes = append(uniqueTxHashes, txHash) + } + + if len(uniqueTxHashes) > limit { + return uniqueTxHashes[len(uniqueTxHashes)-limit:] + } + + return uniqueTxHashes +} + // GetTxHashesForPublicKeyHash gets hashes of confirmed transactions that pays // the given public key hash using either a P2PKH or P2WPKH script. The returned // transactions hashes are ordered by block height in the ascending order, i.e. @@ -461,26 +511,19 @@ func (c *Connection) GetTxHashesForPublicKeyHash( ) } - p2pkhItems, err := c.getConfirmedScriptHistory(p2pkh) - if err != nil { - return nil, fmt.Errorf( - "cannot get P2PKH history for public key hash [0x%x]: [%v]", - publicKeyHash, - err, - ) - } + return c.GetTxHashesForPublicKeyScripts([]bitcoin.Script{p2pkh, p2wpkh}) +} - p2wpkhItems, err := c.getConfirmedScriptHistory(p2wpkh) +// GetTxHashesForPublicKeyScripts gets hashes of confirmed transactions that +// pay to any of the given public key scripts. +func (c *Connection) GetTxHashesForPublicKeyScripts( + publicKeyScripts []bitcoin.Script, +) ([]bitcoin.Hash, error) { + items, err := c.getConfirmedScriptHistories(publicKeyScripts) if err != nil { - return nil, fmt.Errorf( - "cannot get P2WPKH history for public key hash [0x%x]: [%v]", - publicKeyHash, - err, - ) + return nil, err } - items := append(p2pkhItems, p2wpkhItems...) - sort.SliceStable( items, func(i, j int) bool { @@ -496,6 +539,27 @@ func (c *Connection) GetTxHashesForPublicKeyHash( return txHashes, nil } +func (c *Connection) getConfirmedScriptHistories( + publicKeyScripts []bitcoin.Script, +) ([]*scriptHistoryItem, error) { + items := make([]*scriptHistoryItem, 0) + + for _, publicKeyScript := range publicKeyScripts { + scriptItems, err := c.getConfirmedScriptHistory(publicKeyScript) + if err != nil { + return nil, fmt.Errorf( + "cannot get history for script [0x%x]: [%v]", + publicKeyScript, + err, + ) + } + + items = append(items, scriptItems...) + } + + return items, nil +} + type scriptHistoryItem struct { txHash bitcoin.Hash blockHeight int32 @@ -752,45 +816,15 @@ func (c *Connection) GetUtxosForPublicKeyHash( ) } - p2pkhItems, err := c.getScriptUtxos(p2pkh, true) - if err != nil { - return nil, fmt.Errorf( - "cannot get P2PKH UTXOs for public key hash [0x%x]: [%v]", - publicKeyHash, - err, - ) - } - - p2wpkhItems, err := c.getScriptUtxos(p2wpkh, true) - if err != nil { - return nil, fmt.Errorf( - "cannot get P2WPKH UTXOs for public key hash [0x%x]: [%v]", - publicKeyHash, - err, - ) - } - - items := append(p2pkhItems, p2wpkhItems...) - - sort.SliceStable( - items, - func(i, j int) bool { - return items[i].blockHeight < items[j].blockHeight - }, - ) - - utxos := make([]*bitcoin.UnspentTransactionOutput, len(items)) - for i, item := range items { - utxos[i] = &bitcoin.UnspentTransactionOutput{ - Outpoint: &bitcoin.TransactionOutpoint{ - TransactionHash: item.txHash, - OutputIndex: item.outputIndex, - }, - Value: int64(item.value), - } - } + return c.GetUtxosForPublicKeyScripts([]bitcoin.Script{p2pkh, p2wpkh}) +} - return utxos, nil +// GetUtxosForPublicKeyScripts gets unspent outputs of confirmed transactions +// that are controlled by any of the given public key scripts. +func (c *Connection) GetUtxosForPublicKeyScripts( + publicKeyScripts []bitcoin.Script, +) ([]*bitcoin.UnspentTransactionOutput, error) { + return c.getUtxosForPublicKeyScripts(publicKeyScripts, true) } // GetMempoolUtxosForPublicKeyHash gets unspent outputs of unconfirmed transactions @@ -820,26 +854,35 @@ func (c *Connection) GetMempoolUtxosForPublicKeyHash( ) } - p2pkhItems, err := c.getScriptUtxos(p2pkh, false) + return c.GetMempoolUtxosForPublicKeyScripts([]bitcoin.Script{p2pkh, p2wpkh}) +} + +// GetMempoolUtxosForPublicKeyScripts gets unspent outputs of unconfirmed +// transactions that are controlled by any of the given public key scripts. +func (c *Connection) GetMempoolUtxosForPublicKeyScripts( + publicKeyScripts []bitcoin.Script, +) ([]*bitcoin.UnspentTransactionOutput, error) { + return c.getUtxosForPublicKeyScripts(publicKeyScripts, false) +} + +func (c *Connection) getUtxosForPublicKeyScripts( + publicKeyScripts []bitcoin.Script, + confirmed bool, +) ([]*bitcoin.UnspentTransactionOutput, error) { + items, err := c.getScriptUtxosForScripts(publicKeyScripts, confirmed) if err != nil { - return nil, fmt.Errorf( - "cannot get P2PKH UTXOs for public key hash [0x%x]: [%v]", - publicKeyHash, - err, - ) + return nil, err } - p2wpkhItems, err := c.getScriptUtxos(p2wpkh, false) - if err != nil { - return nil, fmt.Errorf( - "cannot get P2WPKH UTXOs for public key hash [0x%x]: [%v]", - publicKeyHash, - err, + if confirmed { + sort.SliceStable( + items, + func(i, j int) bool { + return items[i].blockHeight < items[j].blockHeight + }, ) } - items := append(p2pkhItems, p2wpkhItems...) - utxos := make([]*bitcoin.UnspentTransactionOutput, len(items)) for i, item := range items { utxos[i] = &bitcoin.UnspentTransactionOutput{ @@ -854,6 +897,28 @@ func (c *Connection) GetMempoolUtxosForPublicKeyHash( return utxos, nil } +func (c *Connection) getScriptUtxosForScripts( + publicKeyScripts []bitcoin.Script, + confirmed bool, +) ([]*scriptUtxoItem, error) { + items := make([]*scriptUtxoItem, 0) + + for _, publicKeyScript := range publicKeyScripts { + scriptItems, err := c.getScriptUtxos(publicKeyScript, confirmed) + if err != nil { + return nil, fmt.Errorf( + "cannot get UTXOs for script [0x%x]: [%v]", + publicKeyScript, + err, + ) + } + + items = append(items, scriptItems...) + } + + return items, nil +} + type scriptUtxoItem struct { txHash bitcoin.Hash outputIndex uint32 diff --git a/pkg/bitcoin/script_test.go b/pkg/bitcoin/script_test.go index 4af00b1998..6720b3b92b 100644 --- a/pkg/bitcoin/script_test.go +++ b/pkg/bitcoin/script_test.go @@ -9,6 +9,8 @@ import ( "testing" "github.com/btcsuite/btcd/btcec" + btcec2 "github.com/btcsuite/btcd/btcec/v2" + "github.com/btcsuite/btcd/btcec/v2/schnorr" "github.com/keep-network/keep-core/internal/testutils" ) @@ -360,6 +362,111 @@ func TestPayToTaproot(t *testing.T) { testutils.AssertBytesEqual(t, expectedResult, result[:]) } +func TestTaprootLeafHash(t *testing.T) { + script := Script(hexToSlice( + t, + "76a9140102030405060708090a0b0c0d0e0f101112131488ac", + )) + + result, err := TaprootLeafHash(script) + if err != nil { + t.Fatal(err) + } + + expectedResult := hexToSlice( + t, + "37a57b86de2819d2b72a173df46238a7ad295ea1485d3b40e9415daa82b4fdcb", + ) + + testutils.AssertBytesEqual(t, expectedResult, result[:]) +} + +func TestTaprootTweakAndOutputKey(t *testing.T) { + privateKey, _ := btcec2.PrivKeyFromBytes( + hexToSlice( + t, + "0101010101010101010101010101010101010101010101010101010101010101", + ), + ) + + var internalKey [32]byte + copy(internalKey[:], schnorr.SerializePubKey(privateKey.PubKey())) + + refundLeaf := Script(hexToSlice( + t, + "76a9140102030405060708090a0b0c0d0e0f101112131488ac", + )) + + merkleRoot, err := TaprootLeafHash(refundLeaf) + if err != nil { + t.Fatal(err) + } + + tweak, err := TaprootTweak(internalKey, &merkleRoot) + if err != nil { + t.Fatal(err) + } + + expectedTweak := hexToSlice( + t, + "6ca66b4600554f36d490d227669ba78c2d4778a8ecc07565ae2f9e87c28f124a", + ) + + testutils.AssertBytesEqual(t, expectedTweak, tweak[:]) + + outputKey, err := TaprootOutputKey(internalKey, &merkleRoot) + if err != nil { + t.Fatal(err) + } + + expectedOutputKey := hexToSlice( + t, + "b31d6b4f10bcea1dfcace63ce7defda9e718a4340b4b5befef6194488780ef17", + ) + + testutils.AssertBytesEqual(t, expectedOutputKey, outputKey[:]) +} + +func TestPayToTaprootWithScriptTree(t *testing.T) { + privateKey, _ := btcec2.PrivKeyFromBytes( + hexToSlice( + t, + "0202020202020202020202020202020202020202020202020202020202020202", + ), + ) + + var internalKey [32]byte + copy(internalKey[:], schnorr.SerializePubKey(privateKey.PubKey())) + + merkleRootBytes := hexToSlice( + t, + "b2c459126150e0d47063ea7b6d0474a24c39e25908aae5740dd4787b67c6e19a", + ) + var merkleRoot [32]byte + copy(merkleRoot[:], merkleRootBytes) + + result, err := PayToTaprootWithScriptTree(internalKey, merkleRoot) + if err != nil { + t.Fatal(err) + } + + expectedOutputKey := hexToSlice( + t, + "e339710a2348c113ade4a4e7d52bd1c12bc69818f1af7f41e161142701b93c96", + ) + + // Rebuild the expected P2TR script directly to avoid reusing + // PayToTaprootWithScriptTree. + var expectedKey [32]byte + copy(expectedKey[:], expectedOutputKey) + expectedResult, err := PayToTaproot(expectedKey) + if err != nil { + t.Fatal(err) + } + + testutils.AssertBytesEqual(t, expectedResult, result) +} + func TestGetScriptType(t *testing.T) { fromHex := func(hexString string) []byte { bytes, err := hex.DecodeString(hexString) diff --git a/pkg/bitcoin/taproot.go b/pkg/bitcoin/taproot.go new file mode 100644 index 0000000000..b3d44867f5 --- /dev/null +++ b/pkg/bitcoin/taproot.go @@ -0,0 +1,138 @@ +package bitcoin + +import ( + "bytes" + "fmt" + + btcec2 "github.com/btcsuite/btcd/btcec/v2" + "github.com/btcsuite/btcd/btcec/v2/schnorr" + "github.com/btcsuite/btcd/chaincfg/chainhash" +) + +const taprootBaseLeafVersion = 0xc0 + +// TaprootLeafHash computes the BIP-342 TapLeaf hash for a base-version script. +func TaprootLeafHash(script Script) ([32]byte, error) { + var buffer bytes.Buffer + + if err := buffer.WriteByte(taprootBaseLeafVersion); err != nil { + return [32]byte{}, err + } + + scriptLength, err := writeCompactSizeUint(CompactSizeUint(len(script))) + if err != nil { + return [32]byte{}, fmt.Errorf( + "cannot encode taproot script length: [%v]", + err, + ) + } + + if _, err := buffer.Write(scriptLength); err != nil { + return [32]byte{}, err + } + if _, err := buffer.Write(script); err != nil { + return [32]byte{}, err + } + + return taggedHashToArray( + chainhash.TaggedHash(chainhash.TagTapLeaf, buffer.Bytes()), + ), nil +} + +// TaprootTweak computes the BIP-341 TapTweak hash for an x-only internal key +// and optional script merkle root. +func TaprootTweak( + internalKey [32]byte, + merkleRoot *[32]byte, +) ([32]byte, error) { + _, _, tweak, err := taprootTweakScalar(internalKey, merkleRoot) + return tweak, err +} + +// TaprootOutputKey derives the BIP-341 tweaked x-only Taproot output key from +// an x-only internal key and optional script merkle root. +func TaprootOutputKey( + internalKey [32]byte, + merkleRoot *[32]byte, +) ([32]byte, error) { + internalPublicKey, tweakScalar, _, err := taprootTweakScalar( + internalKey, + merkleRoot, + ) + if err != nil { + return [32]byte{}, err + } + + var internalPoint btcec2.JacobianPoint + internalPublicKey.AsJacobian(&internalPoint) + + var tweakPoint btcec2.JacobianPoint + btcec2.ScalarBaseMultNonConst(&tweakScalar, &tweakPoint) + + var outputPoint btcec2.JacobianPoint + btcec2.AddNonConst(&internalPoint, &tweakPoint, &outputPoint) + + if outputPoint.Z.IsZero() { + return [32]byte{}, fmt.Errorf("taproot output key is infinity") + } + + outputPoint.ToAffine() + outputPublicKey := btcec2.NewPublicKey(&outputPoint.X, &outputPoint.Y) + + var outputKey [32]byte + copy(outputKey[:], schnorr.SerializePubKey(outputPublicKey)) + + return outputKey, nil +} + +// PayToTaprootWithScriptTree constructs a P2TR script from an internal key and +// a script merkle root by applying the BIP-341 TapTweak. +func PayToTaprootWithScriptTree( + internalKey [32]byte, + merkleRoot [32]byte, +) (Script, error) { + outputKey, err := TaprootOutputKey(internalKey, &merkleRoot) + if err != nil { + return nil, fmt.Errorf("cannot derive taproot output key: [%v]", err) + } + + return PayToTaproot(outputKey) +} + +func taprootTweakScalar( + internalKey [32]byte, + merkleRoot *[32]byte, +) (*btcec2.PublicKey, btcec2.ModNScalar, [32]byte, error) { + internalPublicKey, err := schnorr.ParsePubKey(internalKey[:]) + if err != nil { + return nil, btcec2.ModNScalar{}, [32]byte{}, fmt.Errorf( + "cannot parse taproot internal key: [%v]", + err, + ) + } + + tweakMessages := [][]byte{internalKey[:]} + if merkleRoot != nil { + tweakMessages = append(tweakMessages, merkleRoot[:]) + } + + tweak := taggedHashToArray( + chainhash.TaggedHash(chainhash.TagTapTweak, tweakMessages...), + ) + + var tweakScalar btcec2.ModNScalar + if overflow := tweakScalar.SetBytes(&tweak); overflow != 0 { + return nil, btcec2.ModNScalar{}, [32]byte{}, fmt.Errorf( + "taproot tweak is greater than or equal to curve order", + ) + } + + return internalPublicKey, tweakScalar, tweak, nil +} + +func taggedHashToArray(hash *chainhash.Hash) [32]byte { + var result [32]byte + copy(result[:], hash[:]) + + return result +} diff --git a/pkg/bitcoin/transaction_builder.go b/pkg/bitcoin/transaction_builder.go index 6e79933175..3624ddc350 100644 --- a/pkg/bitcoin/transaction_builder.go +++ b/pkg/bitcoin/transaction_builder.go @@ -94,7 +94,7 @@ func (tb *TransactionBuilder) AddPublicKeyHashInput( ) } - return tb.addDirectKeySpendInput(utxo, utxoScript, scriptType) + return tb.addDirectKeySpendInput(utxo, utxoScript, scriptType, nil) } // AddTaprootKeyPathInput adds an unsigned input pointing to a UTXO locked @@ -123,13 +123,80 @@ func (tb *TransactionBuilder) AddTaprootKeyPathInput( ) } - return tb.addDirectKeySpendInput(utxo, utxoScript, scriptType) + return tb.addDirectKeySpendInput(utxo, utxoScript, scriptType, nil) +} + +// AddTaprootKeyPathInputWithMerkleRoot adds an unsigned input pointing to a +// UTXO locked using a BIP-341 tweaked P2TR output key and intended to be spent +// using the Taproot key path. +// +// The provided internal key and script merkle root must derive the output key +// committed to by the UTXO script. The merkle root is retained as signing +// metadata so the FROST signer can produce a key-path signature under the same +// Taproot tweak. +func (tb *TransactionBuilder) AddTaprootKeyPathInputWithMerkleRoot( + utxo *UnspentTransactionOutput, + internalKey [32]byte, + merkleRoot [32]byte, +) error { + utxoScript, err := tb.getScript(utxo) + if err != nil { + return fmt.Errorf( + "cannot get locking script for UTXO pointed "+ + "by the input: [%v]", + err, + ) + } + + scriptType := GetScriptType(utxoScript) + if scriptType != P2TRScript { + return fmt.Errorf( + "UTXO pointed by the input is not P2TR", + ) + } + + outputKey, err := ExtractTaprootKey(utxoScript) + if err != nil { + return fmt.Errorf("cannot extract taproot output key: [%v]", err) + } + + expectedOutputKey, err := TaprootOutputKey(internalKey, &merkleRoot) + if err != nil { + return fmt.Errorf("cannot derive taproot output key: [%v]", err) + } + + if !bytes.Equal(outputKey[:], expectedOutputKey[:]) { + return fmt.Errorf( + "taproot output key does not match internal key and merkle root", + ) + } + + return tb.addDirectKeySpendInput(utxo, utxoScript, scriptType, &merkleRoot) +} + +// TaprootKeyPathInputMerkleRoots returns per-input Taproot script merkle roots +// retained by the builder. The returned slice is aligned with transaction +// inputs. Non-Taproot inputs and untweaked Taproot inputs have nil entries. +func (tb *TransactionBuilder) TaprootKeyPathInputMerkleRoots() []*[32]byte { + merkleRoots := make([]*[32]byte, len(tb.sigHashArgs)) + + for i, sigHashArgs := range tb.sigHashArgs { + if sigHashArgs.taprootMerkleRoot == nil { + continue + } + + merkleRoots[i] = new([32]byte) + copy(merkleRoots[i][:], sigHashArgs.taprootMerkleRoot[:]) + } + + return merkleRoots } func (tb *TransactionBuilder) addDirectKeySpendInput( utxo *UnspentTransactionOutput, utxoScript Script, scriptType ScriptType, + taprootMerkleRoot *[32]byte, ) error { // The UTXO was locked using a direct key-spend script, so the scriptCode // required to build the sighash is equivalent to that script. Worth noting @@ -138,11 +205,12 @@ func (tb *TransactionBuilder) addDirectKeySpendInput( // https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki#specification. // That conversion is handled within the `txscript.CalcWitnessSigHash` call. sigHashArgs := &inputSigHashArgs{ - value: utxo.Value, - publicKeyScript: utxoScript, - scriptCode: utxoScript, - scriptType: scriptType, - witness: scriptType == P2WPKHScript || scriptType == P2TRScript, + value: utxo.Value, + publicKeyScript: utxoScript, + scriptCode: utxoScript, + scriptType: scriptType, + taprootMerkleRoot: taprootMerkleRoot, + witness: scriptType == P2WPKHScript || scriptType == P2TRScript, } hash := chainhash.Hash(utxo.Outpoint.TransactionHash) @@ -900,6 +968,10 @@ type inputSigHashArgs struct { // scriptType denotes the locking script type of the UTXO pointed by the // given input. scriptType ScriptType + // taprootMerkleRoot denotes the BIP-341 script merkle root used to tweak + // the P2TR input's output key. It is nil for untweaked P2TR inputs and + // non-Taproot inputs. + taprootMerkleRoot *[32]byte // witness denotes whether the given input point's to a UTXO locked using // a witness script. witness bool diff --git a/pkg/bitcoin/transaction_builder_test.go b/pkg/bitcoin/transaction_builder_test.go index 1a09ced228..74335991ef 100644 --- a/pkg/bitcoin/transaction_builder_test.go +++ b/pkg/bitcoin/transaction_builder_test.go @@ -198,6 +198,184 @@ func TestTransactionBuilder_AddPublicKeyHashInput_AcceptsTaprootKeyPathInputForB }) } +func TestTransactionBuilder_AddTaprootKeyPathInputWithMerkleRoot(t *testing.T) { + localChain := newLocalChain() + builder := NewTransactionBuilder(localChain) + + privateKey, _ := btcec2.PrivKeyFromBytes( + hexToSlice( + t, + "0101010101010101010101010101010101010101010101010101010101010101", + ), + ) + + var internalKey [32]byte + copy(internalKey[:], schnorr.SerializePubKey(privateKey.PubKey())) + + refundLeaf := Script(hexToSlice( + t, + "76a9140102030405060708090a0b0c0d0e0f101112131488ac", + )) + merkleRoot, err := TaprootLeafHash(refundLeaf) + if err != nil { + t.Fatal(err) + } + + outputKey, err := TaprootOutputKey(internalKey, &merkleRoot) + if err != nil { + t.Fatal(err) + } + + lockingScript, err := PayToTaproot(outputKey) + if err != nil { + t.Fatal(err) + } + + inputTransaction := &Transaction{ + Version: 1, + Inputs: []*TransactionInput{ + { + Outpoint: &TransactionOutpoint{ + TransactionHash: Hash{0x01}, + OutputIndex: 0, + }, + Sequence: 0xffffffff, + }, + }, + Outputs: []*TransactionOutput{ + { + Value: 100000, + PublicKeyScript: lockingScript, + }, + }, + Locktime: 0, + } + + if err := localChain.addTransaction(inputTransaction); err != nil { + t.Fatal(err) + } + + inputTransactionUtxo := &UnspentTransactionOutput{ + Outpoint: &TransactionOutpoint{ + TransactionHash: inputTransaction.Hash(), + OutputIndex: 0, + }, + Value: 100000, + } + + if err := builder.AddTaprootKeyPathInputWithMerkleRoot( + inputTransactionUtxo, + internalKey, + merkleRoot, + ); err != nil { + t.Fatal(err) + } + + assertSigHashArgs( + t, + &inputSigHashArgs{ + value: inputTransactionUtxo.Value, + publicKeyScript: lockingScript, + scriptCode: lockingScript, + scriptType: P2TRScript, + taprootMerkleRoot: &merkleRoot, + witness: true, + }, + builder.sigHashArgs[0], + ) + + merkleRoots := builder.TaprootKeyPathInputMerkleRoots() + if len(merkleRoots) != 1 { + t.Fatalf("unexpected merkle roots count: [%v]", len(merkleRoots)) + } + testutils.AssertBytesEqual(t, merkleRoot[:], merkleRoots[0][:]) +} + +func TestTransactionBuilder_AddTaprootKeyPathInputWithMerkleRootRejectsMismatch( + t *testing.T, +) { + localChain := newLocalChain() + builder := NewTransactionBuilder(localChain) + + privateKey, _ := btcec2.PrivKeyFromBytes( + hexToSlice( + t, + "0101010101010101010101010101010101010101010101010101010101010101", + ), + ) + + var internalKey [32]byte + copy(internalKey[:], schnorr.SerializePubKey(privateKey.PubKey())) + + merkleRoot, err := TaprootLeafHash(Script(hexToSlice( + t, + "76a9140102030405060708090a0b0c0d0e0f101112131488ac", + ))) + if err != nil { + t.Fatal(err) + } + + wrongMerkleRoot, err := TaprootLeafHash(Script(hexToSlice( + t, + "76a914ffffffffffffffffffffffffffffffffffffffff88ac", + ))) + if err != nil { + t.Fatal(err) + } + + outputKey, err := TaprootOutputKey(internalKey, &merkleRoot) + if err != nil { + t.Fatal(err) + } + + lockingScript, err := PayToTaproot(outputKey) + if err != nil { + t.Fatal(err) + } + + inputTransaction := &Transaction{ + Version: 1, + Inputs: []*TransactionInput{ + { + Outpoint: &TransactionOutpoint{ + TransactionHash: Hash{0x01}, + OutputIndex: 0, + }, + Sequence: 0xffffffff, + }, + }, + Outputs: []*TransactionOutput{ + { + Value: 100000, + PublicKeyScript: lockingScript, + }, + }, + Locktime: 0, + } + + if err := localChain.addTransaction(inputTransaction); err != nil { + t.Fatal(err) + } + + err = builder.AddTaprootKeyPathInputWithMerkleRoot( + &UnspentTransactionOutput{ + Outpoint: &TransactionOutpoint{ + TransactionHash: inputTransaction.Hash(), + OutputIndex: 0, + }, + Value: 100000, + }, + internalKey, + wrongMerkleRoot, + ) + if err == nil { + t.Fatal("expected taproot output key mismatch error") + } + if !strings.Contains(err.Error(), "taproot output key does not match") { + t.Fatalf("unexpected error: [%v]", err) + } +} + func TestTransactionBuilder_AddInputReturnsErrorForOutOfRangeOutputIndex( t *testing.T, ) { @@ -1315,6 +1493,20 @@ func assertSigHashArgs(t *testing.T, expected, actual *inputSigHashArgs) { ) } + if expected.taprootMerkleRoot != nil { + if actual.taprootMerkleRoot == nil { + t.Fatal("expected taproot merkle root") + } + + testutils.AssertBytesEqual( + t, + expected.taprootMerkleRoot[:], + actual.taprootMerkleRoot[:], + ) + } else if actual.taprootMerkleRoot != nil { + t.Fatal("unexpected taproot merkle root") + } + testutils.AssertBoolsEqual( t, "sighash args witness flag", diff --git a/pkg/chain/ethereum/ethereum.go b/pkg/chain/ethereum/ethereum.go index 57b800edb0..2e42461e42 100644 --- a/pkg/chain/ethereum/ethereum.go +++ b/pkg/chain/ethereum/ethereum.go @@ -339,18 +339,18 @@ func (bc *baseChain) OperatorKeyPair() ( func (bc *baseChain) GetBlockNumberByTimestamp( timestamp uint64, ) (uint64, error) { - block, err := bc.currentBlock() + block, err := bc.currentBlockHeader() if err != nil { return 0, fmt.Errorf("cannot get current block: [%v]", err) } - if block.Time() < timestamp { + if block.Time < timestamp { return 0, fmt.Errorf("requested timestamp is in the future") } // Corner case shortcut. - if block.Time() == timestamp { - return block.NumberU64(), nil + if block.Time == timestamp { + return block.Number.Uint64(), nil } // The Ethereum average block time (https://etherscan.io/chart/blocktime) @@ -366,9 +366,9 @@ func (bc *baseChain) GetBlockNumberByTimestamp( // the better one. const averageBlockTime = 13 - for block.Time() > timestamp { + for block.Time > timestamp { // timeDiff is always >0 due to the for-loop condition. - timeDiff := block.Time() - timestamp + timeDiff := block.Time - timestamp // blockDiff is an integer whose value can be: // - >=1 if timeDiff >= averageBlockTime // - ==0 if timeDiff < averageBlockTime @@ -380,7 +380,7 @@ func (bc *baseChain) GetBlockNumberByTimestamp( break } - block, err = bc.blockByNumber(block.NumberU64() - blockDiff) + block, err = bc.headerByNumber(block.Number.Uint64() - blockDiff) if err != nil { return 0, fmt.Errorf("cannot get block: [%v]", err) } @@ -393,8 +393,8 @@ func (bc *baseChain) GetBlockNumberByTimestamp( // // First, try to reduce Case 1 by walking forward block by block until // we achieve Case 2 or 3. - for block.Time() < timestamp { - block, err = bc.blockByNumber(block.NumberU64() + 1) + for block.Time < timestamp { + block, err = bc.headerByNumber(block.Number.Uint64() + 1) if err != nil { return 0, fmt.Errorf("cannot get block: [%v]", err) } @@ -402,16 +402,16 @@ func (bc *baseChain) GetBlockNumberByTimestamp( // At this point, only Case 2 or 3 are possible. If we have Case 2, // just get the previous block and compare which one lies closer to // the requested timestamp. - if block.Time() > timestamp { - previousBlock, err := bc.blockByNumber(block.NumberU64() - 1) + if block.Time > timestamp { + previousBlock, err := bc.headerByNumber(block.Number.Uint64() - 1) if err != nil { return 0, fmt.Errorf("cannot get block: [%v]", err) } - return closerBlock(timestamp, previousBlock, block).NumberU64(), nil + return closerBlock(timestamp, previousBlock, block).Number.Uint64(), nil } - return block.NumberU64(), nil + return block.Number.Uint64(), nil } // GetBlockHashByNumber gets the block hash for the given block number. @@ -427,14 +427,14 @@ func (bc *baseChain) GetBlockHashByNumber(blockNumber uint64) ( return header.Hash(), nil } -// currentBlock fetches the current block. -func (bc *baseChain) currentBlock() (*types.Block, error) { +// currentBlockHeader fetches the current block header. +func (bc *baseChain) currentBlockHeader() (*types.Header, error) { currentBlockNumber, err := bc.blockCounter.CurrentBlock() if err != nil { return nil, err } - currentBlock, err := bc.blockByNumber(currentBlockNumber) + currentBlock, err := bc.headerByNumber(currentBlockNumber) if err != nil { return nil, err } @@ -442,15 +442,6 @@ func (bc *baseChain) currentBlock() (*types.Block, error) { return currentBlock, nil } -// blockByNumber returns the block for the given block number. Times out -// if the underlying client call takes more than 30 seconds. -func (bc *baseChain) blockByNumber(number uint64) (*types.Block, error) { - ctx, cancelCtx := context.WithTimeout(context.Background(), 30*time.Second) - defer cancelCtx() - - return bc.client.BlockByNumber(ctx, big.NewInt(int64(number))) -} - // headerByNumber returns the header for the given block number. Times out // if the underlying client call takes more than 30 seconds. func (bc *baseChain) headerByNumber(number uint64) (*types.Header, error) { @@ -463,7 +454,7 @@ func (bc *baseChain) headerByNumber(number uint64) (*types.Header, error) { // closerBlock check timestamps of blocks b1 and b2 and returns the block // whose timestamp lies closer to the requested timestamp. If the distance // is same for both blocks, the block with greater block number is returned. -func closerBlock(timestamp uint64, b1, b2 *types.Block) *types.Block { +func closerBlock(timestamp uint64, b1, b2 *types.Header) *types.Header { abs := func(x int64) int64 { if x < 0 { return -x @@ -471,12 +462,12 @@ func closerBlock(timestamp uint64, b1, b2 *types.Block) *types.Block { return x } - b1Diff := abs(int64(b1.Time() - timestamp)) - b2Diff := abs(int64(b2.Time() - timestamp)) + b1Diff := abs(int64(b1.Time - timestamp)) + b2Diff := abs(int64(b2.Time - timestamp)) // If the differences are same, return the block with greater number. if b1Diff == b2Diff { - if b2.NumberU64() > b1.NumberU64() { + if b2.Number.Uint64() > b1.Number.Uint64() { return b2 } return b1 diff --git a/pkg/chain/ethereum/frost/gen/abi/FrostWalletRegistry.go b/pkg/chain/ethereum/frost/gen/abi/FrostWalletRegistry.go index fb4de202e2..a611a3a8a6 100644 --- a/pkg/chain/ethereum/frost/gen/abi/FrostWalletRegistry.go +++ b/pkg/chain/ethereum/frost/gen/abi/FrostWalletRegistry.go @@ -33,11 +33,11 @@ var ( type Struct0 struct { SubmitterMemberIndex *big.Int XOnlyOutputKey [32]byte - MembersHash [32]byte MisbehavedMembersIndices []uint8 Signatures []byte SigningMembersIndices []*big.Int Members []uint32 + MembersHash [32]byte } // Struct1 is an auto generated low-level Go binding around an user-defined struct. @@ -51,7 +51,7 @@ type Struct1 struct { // FrostWalletRegistryMetaData contains all meta data concerning the FrostWalletRegistry contract. var FrostWalletRegistryMetaData = &bind.MetaData{ - ABI: "[{\"type\":\"event\",\"name\":\"DkgStarted\",\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"seed\",\"type\":\"uint256\"}]},{\"type\":\"event\",\"name\":\"DkgResultSubmitted\",\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"resultHash\",\"type\":\"bytes32\"},{\"indexed\":true,\"name\":\"seed\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"result\",\"type\":\"tuple\",\"components\":[{\"name\":\"submitterMemberIndex\",\"type\":\"uint256\"},{\"name\":\"xOnlyOutputKey\",\"type\":\"bytes32\"},{\"name\":\"membersHash\",\"type\":\"bytes32\"},{\"name\":\"misbehavedMembersIndices\",\"type\":\"uint8[]\"},{\"name\":\"signatures\",\"type\":\"bytes\"},{\"name\":\"signingMembersIndices\",\"type\":\"uint256[]\"},{\"name\":\"members\",\"type\":\"uint32[]\"}]}]},{\"type\":\"event\",\"name\":\"DkgResultApproved\",\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"resultHash\",\"type\":\"bytes32\"},{\"indexed\":true,\"name\":\"approver\",\"type\":\"address\"}]},{\"type\":\"event\",\"name\":\"DkgResultChallenged\",\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"resultHash\",\"type\":\"bytes32\"},{\"indexed\":true,\"name\":\"challenger\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"reason\",\"type\":\"string\"}]},{\"type\":\"event\",\"name\":\"DkgTimedOut\",\"anonymous\":false,\"inputs\":[]},{\"type\":\"event\",\"name\":\"DkgSeedTimedOut\",\"anonymous\":false,\"inputs\":[]},{\"type\":\"function\",\"name\":\"submitDkgResult\",\"stateMutability\":\"nonpayable\",\"inputs\":[{\"name\":\"dkgResult\",\"type\":\"tuple\",\"components\":[{\"name\":\"submitterMemberIndex\",\"type\":\"uint256\"},{\"name\":\"xOnlyOutputKey\",\"type\":\"bytes32\"},{\"name\":\"membersHash\",\"type\":\"bytes32\"},{\"name\":\"misbehavedMembersIndices\",\"type\":\"uint8[]\"},{\"name\":\"signatures\",\"type\":\"bytes\"},{\"name\":\"signingMembersIndices\",\"type\":\"uint256[]\"},{\"name\":\"members\",\"type\":\"uint32[]\"}]}],\"outputs\":[]},{\"type\":\"function\",\"name\":\"approveDkgResult\",\"stateMutability\":\"nonpayable\",\"inputs\":[{\"name\":\"dkgResult\",\"type\":\"tuple\",\"components\":[{\"name\":\"submitterMemberIndex\",\"type\":\"uint256\"},{\"name\":\"xOnlyOutputKey\",\"type\":\"bytes32\"},{\"name\":\"membersHash\",\"type\":\"bytes32\"},{\"name\":\"misbehavedMembersIndices\",\"type\":\"uint8[]\"},{\"name\":\"signatures\",\"type\":\"bytes\"},{\"name\":\"signingMembersIndices\",\"type\":\"uint256[]\"},{\"name\":\"members\",\"type\":\"uint32[]\"}]}],\"outputs\":[]},{\"type\":\"function\",\"name\":\"challengeDkgResult\",\"stateMutability\":\"nonpayable\",\"inputs\":[{\"name\":\"dkgResult\",\"type\":\"tuple\",\"components\":[{\"name\":\"submitterMemberIndex\",\"type\":\"uint256\"},{\"name\":\"xOnlyOutputKey\",\"type\":\"bytes32\"},{\"name\":\"membersHash\",\"type\":\"bytes32\"},{\"name\":\"misbehavedMembersIndices\",\"type\":\"uint8[]\"},{\"name\":\"signatures\",\"type\":\"bytes\"},{\"name\":\"signingMembersIndices\",\"type\":\"uint256[]\"},{\"name\":\"members\",\"type\":\"uint32[]\"}]}],\"outputs\":[]},{\"type\":\"function\",\"name\":\"notifyDkgTimeout\",\"stateMutability\":\"nonpayable\",\"inputs\":[],\"outputs\":[]},{\"type\":\"function\",\"name\":\"notifySeedTimeout\",\"stateMutability\":\"nonpayable\",\"inputs\":[],\"outputs\":[]},{\"type\":\"function\",\"name\":\"isDkgResultValid\",\"stateMutability\":\"view\",\"inputs\":[{\"name\":\"result\",\"type\":\"tuple\",\"components\":[{\"name\":\"submitterMemberIndex\",\"type\":\"uint256\"},{\"name\":\"xOnlyOutputKey\",\"type\":\"bytes32\"},{\"name\":\"membersHash\",\"type\":\"bytes32\"},{\"name\":\"misbehavedMembersIndices\",\"type\":\"uint8[]\"},{\"name\":\"signatures\",\"type\":\"bytes\"},{\"name\":\"signingMembersIndices\",\"type\":\"uint256[]\"},{\"name\":\"members\",\"type\":\"uint32[]\"}]}],\"outputs\":[{\"name\":\"\",\"type\":\"bool\"},{\"name\":\"\",\"type\":\"string\"}]},{\"type\":\"function\",\"name\":\"getWalletCreationState\",\"stateMutability\":\"view\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint8\"}]},{\"type\":\"function\",\"name\":\"selectGroup\",\"stateMutability\":\"view\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint32[]\"}]},{\"type\":\"function\",\"name\":\"sortitionPool\",\"stateMutability\":\"view\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\"}]},{\"type\":\"function\",\"name\":\"dkgParameters\",\"stateMutability\":\"view\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"tuple\",\"components\":[{\"name\":\"seedTimeout\",\"type\":\"uint256\"},{\"name\":\"resultChallengePeriodLength\",\"type\":\"uint256\"},{\"name\":\"resultChallengeExtraGas\",\"type\":\"uint256\"},{\"name\":\"resultSubmissionTimeout\",\"type\":\"uint256\"},{\"name\":\"submitterPrecedencePeriodLength\",\"type\":\"uint256\"}]}]}]", + ABI: "[{\"type\":\"event\",\"name\":\"DkgStarted\",\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"seed\",\"type\":\"uint256\"}]},{\"type\":\"event\",\"name\":\"DkgResultSubmitted\",\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"resultHash\",\"type\":\"bytes32\"},{\"indexed\":true,\"name\":\"seed\",\"type\":\"uint256\"},{\"indexed\":false,\"name\":\"result\",\"type\":\"tuple\",\"components\":[{\"name\":\"submitterMemberIndex\",\"type\":\"uint256\"},{\"name\":\"xOnlyOutputKey\",\"type\":\"bytes32\"},{\"name\":\"misbehavedMembersIndices\",\"type\":\"uint8[]\"},{\"name\":\"signatures\",\"type\":\"bytes\"},{\"name\":\"signingMembersIndices\",\"type\":\"uint256[]\"},{\"name\":\"members\",\"type\":\"uint32[]\"},{\"name\":\"membersHash\",\"type\":\"bytes32\"}]}]},{\"type\":\"event\",\"name\":\"DkgResultApproved\",\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"resultHash\",\"type\":\"bytes32\"},{\"indexed\":true,\"name\":\"approver\",\"type\":\"address\"}]},{\"type\":\"event\",\"name\":\"DkgResultChallenged\",\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"name\":\"resultHash\",\"type\":\"bytes32\"},{\"indexed\":true,\"name\":\"challenger\",\"type\":\"address\"},{\"indexed\":false,\"name\":\"reason\",\"type\":\"string\"}]},{\"type\":\"event\",\"name\":\"DkgTimedOut\",\"anonymous\":false,\"inputs\":[]},{\"type\":\"event\",\"name\":\"DkgSeedTimedOut\",\"anonymous\":false,\"inputs\":[]},{\"type\":\"function\",\"name\":\"submitDkgResult\",\"stateMutability\":\"nonpayable\",\"inputs\":[{\"name\":\"dkgResult\",\"type\":\"tuple\",\"components\":[{\"name\":\"submitterMemberIndex\",\"type\":\"uint256\"},{\"name\":\"xOnlyOutputKey\",\"type\":\"bytes32\"},{\"name\":\"misbehavedMembersIndices\",\"type\":\"uint8[]\"},{\"name\":\"signatures\",\"type\":\"bytes\"},{\"name\":\"signingMembersIndices\",\"type\":\"uint256[]\"},{\"name\":\"members\",\"type\":\"uint32[]\"},{\"name\":\"membersHash\",\"type\":\"bytes32\"}]}],\"outputs\":[]},{\"type\":\"function\",\"name\":\"approveDkgResult\",\"stateMutability\":\"nonpayable\",\"inputs\":[{\"name\":\"dkgResult\",\"type\":\"tuple\",\"components\":[{\"name\":\"submitterMemberIndex\",\"type\":\"uint256\"},{\"name\":\"xOnlyOutputKey\",\"type\":\"bytes32\"},{\"name\":\"misbehavedMembersIndices\",\"type\":\"uint8[]\"},{\"name\":\"signatures\",\"type\":\"bytes\"},{\"name\":\"signingMembersIndices\",\"type\":\"uint256[]\"},{\"name\":\"members\",\"type\":\"uint32[]\"},{\"name\":\"membersHash\",\"type\":\"bytes32\"}]}],\"outputs\":[]},{\"type\":\"function\",\"name\":\"challengeDkgResult\",\"stateMutability\":\"nonpayable\",\"inputs\":[{\"name\":\"dkgResult\",\"type\":\"tuple\",\"components\":[{\"name\":\"submitterMemberIndex\",\"type\":\"uint256\"},{\"name\":\"xOnlyOutputKey\",\"type\":\"bytes32\"},{\"name\":\"misbehavedMembersIndices\",\"type\":\"uint8[]\"},{\"name\":\"signatures\",\"type\":\"bytes\"},{\"name\":\"signingMembersIndices\",\"type\":\"uint256[]\"},{\"name\":\"members\",\"type\":\"uint32[]\"},{\"name\":\"membersHash\",\"type\":\"bytes32\"}]}],\"outputs\":[]},{\"type\":\"function\",\"name\":\"notifyDkgTimeout\",\"stateMutability\":\"nonpayable\",\"inputs\":[],\"outputs\":[]},{\"type\":\"function\",\"name\":\"notifySeedTimeout\",\"stateMutability\":\"nonpayable\",\"inputs\":[],\"outputs\":[]},{\"type\":\"function\",\"name\":\"isDkgResultValid\",\"stateMutability\":\"view\",\"inputs\":[{\"name\":\"result\",\"type\":\"tuple\",\"components\":[{\"name\":\"submitterMemberIndex\",\"type\":\"uint256\"},{\"name\":\"xOnlyOutputKey\",\"type\":\"bytes32\"},{\"name\":\"misbehavedMembersIndices\",\"type\":\"uint8[]\"},{\"name\":\"signatures\",\"type\":\"bytes\"},{\"name\":\"signingMembersIndices\",\"type\":\"uint256[]\"},{\"name\":\"members\",\"type\":\"uint32[]\"},{\"name\":\"membersHash\",\"type\":\"bytes32\"}]}],\"outputs\":[{\"name\":\"\",\"type\":\"bool\"},{\"name\":\"\",\"type\":\"string\"}]},{\"type\":\"function\",\"name\":\"getWalletCreationState\",\"stateMutability\":\"view\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint8\"}]},{\"type\":\"function\",\"name\":\"selectGroup\",\"stateMutability\":\"view\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"uint32[]\"}]},{\"type\":\"function\",\"name\":\"sortitionPool\",\"stateMutability\":\"view\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"address\"}]},{\"type\":\"function\",\"name\":\"dkgParameters\",\"stateMutability\":\"view\",\"inputs\":[],\"outputs\":[{\"name\":\"\",\"type\":\"tuple\",\"components\":[{\"name\":\"seedTimeout\",\"type\":\"uint256\"},{\"name\":\"resultChallengePeriodLength\",\"type\":\"uint256\"},{\"name\":\"resultChallengeExtraGas\",\"type\":\"uint256\"},{\"name\":\"resultSubmissionTimeout\",\"type\":\"uint256\"},{\"name\":\"submitterPrecedencePeriodLength\",\"type\":\"uint256\"}]}]}]", } // FrostWalletRegistryABI is the input ABI used to generate the binding from. @@ -262,9 +262,9 @@ func (_FrostWalletRegistry *FrostWalletRegistryCallerSession) GetWalletCreationS return _FrostWalletRegistry.Contract.GetWalletCreationState(&_FrostWalletRegistry.CallOpts) } -// IsDkgResultValid is a free data retrieval call binding the contract method 0x2fd29068. +// IsDkgResultValid is a free data retrieval call binding the contract method 0x3b74e062. // -// Solidity: function isDkgResultValid((uint256,bytes32,bytes32,uint8[],bytes,uint256[],uint32[]) result) view returns(bool, string) +// Solidity: function isDkgResultValid((uint256,bytes32,uint8[],bytes,uint256[],uint32[],bytes32) result) view returns(bool, string) func (_FrostWalletRegistry *FrostWalletRegistryCaller) IsDkgResultValid(opts *bind.CallOpts, result Struct0) (bool, string, error) { var out []interface{} err := _FrostWalletRegistry.contract.Call(opts, &out, "isDkgResultValid", result) @@ -280,16 +280,16 @@ func (_FrostWalletRegistry *FrostWalletRegistryCaller) IsDkgResultValid(opts *bi } -// IsDkgResultValid is a free data retrieval call binding the contract method 0x2fd29068. +// IsDkgResultValid is a free data retrieval call binding the contract method 0x3b74e062. // -// Solidity: function isDkgResultValid((uint256,bytes32,bytes32,uint8[],bytes,uint256[],uint32[]) result) view returns(bool, string) +// Solidity: function isDkgResultValid((uint256,bytes32,uint8[],bytes,uint256[],uint32[],bytes32) result) view returns(bool, string) func (_FrostWalletRegistry *FrostWalletRegistrySession) IsDkgResultValid(result Struct0) (bool, string, error) { return _FrostWalletRegistry.Contract.IsDkgResultValid(&_FrostWalletRegistry.CallOpts, result) } -// IsDkgResultValid is a free data retrieval call binding the contract method 0x2fd29068. +// IsDkgResultValid is a free data retrieval call binding the contract method 0x3b74e062. // -// Solidity: function isDkgResultValid((uint256,bytes32,bytes32,uint8[],bytes,uint256[],uint32[]) result) view returns(bool, string) +// Solidity: function isDkgResultValid((uint256,bytes32,uint8[],bytes,uint256[],uint32[],bytes32) result) view returns(bool, string) func (_FrostWalletRegistry *FrostWalletRegistryCallerSession) IsDkgResultValid(result Struct0) (bool, string, error) { return _FrostWalletRegistry.Contract.IsDkgResultValid(&_FrostWalletRegistry.CallOpts, result) } @@ -356,44 +356,44 @@ func (_FrostWalletRegistry *FrostWalletRegistryCallerSession) SortitionPool() (c return _FrostWalletRegistry.Contract.SortitionPool(&_FrostWalletRegistry.CallOpts) } -// ApproveDkgResult is a paid mutator transaction binding the contract method 0x65b514e2. +// ApproveDkgResult is a paid mutator transaction binding the contract method 0xcf2feddd. // -// Solidity: function approveDkgResult((uint256,bytes32,bytes32,uint8[],bytes,uint256[],uint32[]) dkgResult) returns() +// Solidity: function approveDkgResult((uint256,bytes32,uint8[],bytes,uint256[],uint32[],bytes32) dkgResult) returns() func (_FrostWalletRegistry *FrostWalletRegistryTransactor) ApproveDkgResult(opts *bind.TransactOpts, dkgResult Struct0) (*types.Transaction, error) { return _FrostWalletRegistry.contract.Transact(opts, "approveDkgResult", dkgResult) } -// ApproveDkgResult is a paid mutator transaction binding the contract method 0x65b514e2. +// ApproveDkgResult is a paid mutator transaction binding the contract method 0xcf2feddd. // -// Solidity: function approveDkgResult((uint256,bytes32,bytes32,uint8[],bytes,uint256[],uint32[]) dkgResult) returns() +// Solidity: function approveDkgResult((uint256,bytes32,uint8[],bytes,uint256[],uint32[],bytes32) dkgResult) returns() func (_FrostWalletRegistry *FrostWalletRegistrySession) ApproveDkgResult(dkgResult Struct0) (*types.Transaction, error) { return _FrostWalletRegistry.Contract.ApproveDkgResult(&_FrostWalletRegistry.TransactOpts, dkgResult) } -// ApproveDkgResult is a paid mutator transaction binding the contract method 0x65b514e2. +// ApproveDkgResult is a paid mutator transaction binding the contract method 0xcf2feddd. // -// Solidity: function approveDkgResult((uint256,bytes32,bytes32,uint8[],bytes,uint256[],uint32[]) dkgResult) returns() +// Solidity: function approveDkgResult((uint256,bytes32,uint8[],bytes,uint256[],uint32[],bytes32) dkgResult) returns() func (_FrostWalletRegistry *FrostWalletRegistryTransactorSession) ApproveDkgResult(dkgResult Struct0) (*types.Transaction, error) { return _FrostWalletRegistry.Contract.ApproveDkgResult(&_FrostWalletRegistry.TransactOpts, dkgResult) } -// ChallengeDkgResult is a paid mutator transaction binding the contract method 0xf10f610b. +// ChallengeDkgResult is a paid mutator transaction binding the contract method 0x24ac833e. // -// Solidity: function challengeDkgResult((uint256,bytes32,bytes32,uint8[],bytes,uint256[],uint32[]) dkgResult) returns() +// Solidity: function challengeDkgResult((uint256,bytes32,uint8[],bytes,uint256[],uint32[],bytes32) dkgResult) returns() func (_FrostWalletRegistry *FrostWalletRegistryTransactor) ChallengeDkgResult(opts *bind.TransactOpts, dkgResult Struct0) (*types.Transaction, error) { return _FrostWalletRegistry.contract.Transact(opts, "challengeDkgResult", dkgResult) } -// ChallengeDkgResult is a paid mutator transaction binding the contract method 0xf10f610b. +// ChallengeDkgResult is a paid mutator transaction binding the contract method 0x24ac833e. // -// Solidity: function challengeDkgResult((uint256,bytes32,bytes32,uint8[],bytes,uint256[],uint32[]) dkgResult) returns() +// Solidity: function challengeDkgResult((uint256,bytes32,uint8[],bytes,uint256[],uint32[],bytes32) dkgResult) returns() func (_FrostWalletRegistry *FrostWalletRegistrySession) ChallengeDkgResult(dkgResult Struct0) (*types.Transaction, error) { return _FrostWalletRegistry.Contract.ChallengeDkgResult(&_FrostWalletRegistry.TransactOpts, dkgResult) } -// ChallengeDkgResult is a paid mutator transaction binding the contract method 0xf10f610b. +// ChallengeDkgResult is a paid mutator transaction binding the contract method 0x24ac833e. // -// Solidity: function challengeDkgResult((uint256,bytes32,bytes32,uint8[],bytes,uint256[],uint32[]) dkgResult) returns() +// Solidity: function challengeDkgResult((uint256,bytes32,uint8[],bytes,uint256[],uint32[],bytes32) dkgResult) returns() func (_FrostWalletRegistry *FrostWalletRegistryTransactorSession) ChallengeDkgResult(dkgResult Struct0) (*types.Transaction, error) { return _FrostWalletRegistry.Contract.ChallengeDkgResult(&_FrostWalletRegistry.TransactOpts, dkgResult) } @@ -440,23 +440,23 @@ func (_FrostWalletRegistry *FrostWalletRegistryTransactorSession) NotifySeedTime return _FrostWalletRegistry.Contract.NotifySeedTimeout(&_FrostWalletRegistry.TransactOpts) } -// SubmitDkgResult is a paid mutator transaction binding the contract method 0xd776003c. +// SubmitDkgResult is a paid mutator transaction binding the contract method 0x55129e3a. // -// Solidity: function submitDkgResult((uint256,bytes32,bytes32,uint8[],bytes,uint256[],uint32[]) dkgResult) returns() +// Solidity: function submitDkgResult((uint256,bytes32,uint8[],bytes,uint256[],uint32[],bytes32) dkgResult) returns() func (_FrostWalletRegistry *FrostWalletRegistryTransactor) SubmitDkgResult(opts *bind.TransactOpts, dkgResult Struct0) (*types.Transaction, error) { return _FrostWalletRegistry.contract.Transact(opts, "submitDkgResult", dkgResult) } -// SubmitDkgResult is a paid mutator transaction binding the contract method 0xd776003c. +// SubmitDkgResult is a paid mutator transaction binding the contract method 0x55129e3a. // -// Solidity: function submitDkgResult((uint256,bytes32,bytes32,uint8[],bytes,uint256[],uint32[]) dkgResult) returns() +// Solidity: function submitDkgResult((uint256,bytes32,uint8[],bytes,uint256[],uint32[],bytes32) dkgResult) returns() func (_FrostWalletRegistry *FrostWalletRegistrySession) SubmitDkgResult(dkgResult Struct0) (*types.Transaction, error) { return _FrostWalletRegistry.Contract.SubmitDkgResult(&_FrostWalletRegistry.TransactOpts, dkgResult) } -// SubmitDkgResult is a paid mutator transaction binding the contract method 0xd776003c. +// SubmitDkgResult is a paid mutator transaction binding the contract method 0x55129e3a. // -// Solidity: function submitDkgResult((uint256,bytes32,bytes32,uint8[],bytes,uint256[],uint32[]) dkgResult) returns() +// Solidity: function submitDkgResult((uint256,bytes32,uint8[],bytes,uint256[],uint32[],bytes32) dkgResult) returns() func (_FrostWalletRegistry *FrostWalletRegistryTransactorSession) SubmitDkgResult(dkgResult Struct0) (*types.Transaction, error) { return _FrostWalletRegistry.Contract.SubmitDkgResult(&_FrostWalletRegistry.TransactOpts, dkgResult) } @@ -843,9 +843,9 @@ type FrostWalletRegistryDkgResultSubmitted struct { Raw types.Log // Blockchain specific contextual infos } -// FilterDkgResultSubmitted is a free log retrieval operation binding the contract event 0x4384430e6f3647db226a1f2644148e4c22a002f0e84329434dab4a0f5d5b59aa. +// FilterDkgResultSubmitted is a free log retrieval operation binding the contract event 0xbfc6cd6291b6741d3ac1631ba81a0288d08265bea4d59d452e8c953e11ec11c6. // -// Solidity: event DkgResultSubmitted(bytes32 indexed resultHash, uint256 indexed seed, (uint256,bytes32,bytes32,uint8[],bytes,uint256[],uint32[]) result) +// Solidity: event DkgResultSubmitted(bytes32 indexed resultHash, uint256 indexed seed, (uint256,bytes32,uint8[],bytes,uint256[],uint32[],bytes32) result) func (_FrostWalletRegistry *FrostWalletRegistryFilterer) FilterDkgResultSubmitted(opts *bind.FilterOpts, resultHash [][32]byte, seed []*big.Int) (*FrostWalletRegistryDkgResultSubmittedIterator, error) { var resultHashRule []interface{} @@ -864,9 +864,9 @@ func (_FrostWalletRegistry *FrostWalletRegistryFilterer) FilterDkgResultSubmitte return &FrostWalletRegistryDkgResultSubmittedIterator{contract: _FrostWalletRegistry.contract, event: "DkgResultSubmitted", logs: logs, sub: sub}, nil } -// WatchDkgResultSubmitted is a free log subscription operation binding the contract event 0x4384430e6f3647db226a1f2644148e4c22a002f0e84329434dab4a0f5d5b59aa. +// WatchDkgResultSubmitted is a free log subscription operation binding the contract event 0xbfc6cd6291b6741d3ac1631ba81a0288d08265bea4d59d452e8c953e11ec11c6. // -// Solidity: event DkgResultSubmitted(bytes32 indexed resultHash, uint256 indexed seed, (uint256,bytes32,bytes32,uint8[],bytes,uint256[],uint32[]) result) +// Solidity: event DkgResultSubmitted(bytes32 indexed resultHash, uint256 indexed seed, (uint256,bytes32,uint8[],bytes,uint256[],uint32[],bytes32) result) func (_FrostWalletRegistry *FrostWalletRegistryFilterer) WatchDkgResultSubmitted(opts *bind.WatchOpts, sink chan<- *FrostWalletRegistryDkgResultSubmitted, resultHash [][32]byte, seed []*big.Int) (event.Subscription, error) { var resultHashRule []interface{} @@ -910,9 +910,9 @@ func (_FrostWalletRegistry *FrostWalletRegistryFilterer) WatchDkgResultSubmitted }), nil } -// ParseDkgResultSubmitted is a log parse operation binding the contract event 0x4384430e6f3647db226a1f2644148e4c22a002f0e84329434dab4a0f5d5b59aa. +// ParseDkgResultSubmitted is a log parse operation binding the contract event 0xbfc6cd6291b6741d3ac1631ba81a0288d08265bea4d59d452e8c953e11ec11c6. // -// Solidity: event DkgResultSubmitted(bytes32 indexed resultHash, uint256 indexed seed, (uint256,bytes32,bytes32,uint8[],bytes,uint256[],uint32[]) result) +// Solidity: event DkgResultSubmitted(bytes32 indexed resultHash, uint256 indexed seed, (uint256,bytes32,uint8[],bytes,uint256[],uint32[],bytes32) result) func (_FrostWalletRegistry *FrostWalletRegistryFilterer) ParseDkgResultSubmitted(log types.Log) (*FrostWalletRegistryDkgResultSubmitted, error) { event := new(FrostWalletRegistryDkgResultSubmitted) if err := _FrostWalletRegistry.contract.UnpackLog(event, "DkgResultSubmitted", log); err != nil { diff --git a/pkg/chain/ethereum/frost/gen/validatorabi/FrostDkgValidator.go b/pkg/chain/ethereum/frost/gen/validatorabi/FrostDkgValidator.go index 8adb0c81fd..6c91757aab 100644 --- a/pkg/chain/ethereum/frost/gen/validatorabi/FrostDkgValidator.go +++ b/pkg/chain/ethereum/frost/gen/validatorabi/FrostDkgValidator.go @@ -33,16 +33,16 @@ var ( type Struct0 struct { SubmitterMemberIndex *big.Int XOnlyOutputKey [32]byte - MembersHash [32]byte MisbehavedMembersIndices []uint8 Signatures []byte SigningMembersIndices []*big.Int Members []uint32 + MembersHash [32]byte } // FrostDkgValidatorMetaData contains all meta data concerning the FrostDkgValidator contract. var FrostDkgValidatorMetaData = &bind.MetaData{ - ABI: "[{\"type\":\"function\",\"name\":\"resultDigest\",\"stateMutability\":\"view\",\"inputs\":[{\"name\":\"result\",\"type\":\"tuple\",\"components\":[{\"name\":\"submitterMemberIndex\",\"type\":\"uint256\"},{\"name\":\"xOnlyOutputKey\",\"type\":\"bytes32\"},{\"name\":\"membersHash\",\"type\":\"bytes32\"},{\"name\":\"misbehavedMembersIndices\",\"type\":\"uint8[]\"},{\"name\":\"signatures\",\"type\":\"bytes\"},{\"name\":\"signingMembersIndices\",\"type\":\"uint256[]\"},{\"name\":\"members\",\"type\":\"uint32[]\"}]},{\"name\":\"seed\",\"type\":\"uint256\"},{\"name\":\"bridge\",\"type\":\"address\"},{\"name\":\"registry\",\"type\":\"address\"}],\"outputs\":[{\"name\":\"digest\",\"type\":\"bytes32\"}]}]", + ABI: "[{\"type\":\"function\",\"name\":\"resultDigest\",\"stateMutability\":\"view\",\"inputs\":[{\"name\":\"result\",\"type\":\"tuple\",\"components\":[{\"name\":\"submitterMemberIndex\",\"type\":\"uint256\"},{\"name\":\"xOnlyOutputKey\",\"type\":\"bytes32\"},{\"name\":\"misbehavedMembersIndices\",\"type\":\"uint8[]\"},{\"name\":\"signatures\",\"type\":\"bytes\"},{\"name\":\"signingMembersIndices\",\"type\":\"uint256[]\"},{\"name\":\"members\",\"type\":\"uint32[]\"},{\"name\":\"membersHash\",\"type\":\"bytes32\"}]},{\"name\":\"seed\",\"type\":\"uint256\"},{\"name\":\"bridge\",\"type\":\"address\"},{\"name\":\"registry\",\"type\":\"address\"}],\"outputs\":[{\"name\":\"digest\",\"type\":\"bytes32\"}]}]", } // FrostDkgValidatorABI is the input ABI used to generate the binding from. @@ -191,9 +191,9 @@ func (_FrostDkgValidator *FrostDkgValidatorTransactorRaw) Transact(opts *bind.Tr return _FrostDkgValidator.Contract.contract.Transact(opts, method, params...) } -// ResultDigest is a free data retrieval call binding the contract method 0x4669f2d6. +// ResultDigest is a free data retrieval call binding the contract method 0xa63415cd. // -// Solidity: function resultDigest((uint256,bytes32,bytes32,uint8[],bytes,uint256[],uint32[]) result, uint256 seed, address bridge, address registry) view returns(bytes32 digest) +// Solidity: function resultDigest((uint256,bytes32,uint8[],bytes,uint256[],uint32[],bytes32) result, uint256 seed, address bridge, address registry) view returns(bytes32 digest) func (_FrostDkgValidator *FrostDkgValidatorCaller) ResultDigest(opts *bind.CallOpts, result Struct0, seed *big.Int, bridge common.Address, registry common.Address) ([32]byte, error) { var out []interface{} err := _FrostDkgValidator.contract.Call(opts, &out, "resultDigest", result, seed, bridge, registry) @@ -208,16 +208,16 @@ func (_FrostDkgValidator *FrostDkgValidatorCaller) ResultDigest(opts *bind.CallO } -// ResultDigest is a free data retrieval call binding the contract method 0x4669f2d6. +// ResultDigest is a free data retrieval call binding the contract method 0xa63415cd. // -// Solidity: function resultDigest((uint256,bytes32,bytes32,uint8[],bytes,uint256[],uint32[]) result, uint256 seed, address bridge, address registry) view returns(bytes32 digest) +// Solidity: function resultDigest((uint256,bytes32,uint8[],bytes,uint256[],uint32[],bytes32) result, uint256 seed, address bridge, address registry) view returns(bytes32 digest) func (_FrostDkgValidator *FrostDkgValidatorSession) ResultDigest(result Struct0, seed *big.Int, bridge common.Address, registry common.Address) ([32]byte, error) { return _FrostDkgValidator.Contract.ResultDigest(&_FrostDkgValidator.CallOpts, result, seed, bridge, registry) } -// ResultDigest is a free data retrieval call binding the contract method 0x4669f2d6. +// ResultDigest is a free data retrieval call binding the contract method 0xa63415cd. // -// Solidity: function resultDigest((uint256,bytes32,bytes32,uint8[],bytes,uint256[],uint32[]) result, uint256 seed, address bridge, address registry) view returns(bytes32 digest) +// Solidity: function resultDigest((uint256,bytes32,uint8[],bytes,uint256[],uint32[],bytes32) result, uint256 seed, address bridge, address registry) view returns(bytes32 digest) func (_FrostDkgValidator *FrostDkgValidatorCallerSession) ResultDigest(result Struct0, seed *big.Int, bridge common.Address, registry common.Address) ([32]byte, error) { return _FrostDkgValidator.Contract.ResultDigest(&_FrostDkgValidator.CallOpts, result, seed, bridge, registry) } diff --git a/pkg/chain/ethereum/frost_bindings_test.go b/pkg/chain/ethereum/frost_bindings_test.go new file mode 100644 index 0000000000..196928b995 --- /dev/null +++ b/pkg/chain/ethereum/frost_bindings_test.go @@ -0,0 +1,120 @@ +package ethereum + +import ( + "bytes" + "reflect" + "testing" + + "github.com/ethereum/go-ethereum/crypto" + frostabi "github.com/keep-network/keep-core/pkg/chain/ethereum/frost/gen/abi" + frostvalidatorabi "github.com/keep-network/keep-core/pkg/chain/ethereum/frost/gen/validatorabi" +) + +const frostDkgResultTupleSignature = "(uint256,bytes32,uint8[],bytes,uint256[],uint32[],bytes32)" + +func TestFrostGeneratedBindingsUseDeployedDkgResultTupleOrder(t *testing.T) { + expectedFields := []string{ + "SubmitterMemberIndex", + "XOnlyOutputKey", + "MisbehavedMembersIndices", + "Signatures", + "SigningMembersIndices", + "Members", + "MembersHash", + } + + assertStructFieldOrder(t, reflect.TypeOf(frostabi.Struct0{}), expectedFields) + assertStructFieldOrder(t, reflect.TypeOf(frostvalidatorabi.Struct0{}), expectedFields) + + walletRegistryABI, err := frostabi.FrostWalletRegistryMetaData.GetAbi() + if err != nil { + t.Fatal(err) + } + + for _, method := range []string{ + "submitDkgResult", + "approveDkgResult", + "challengeDkgResult", + "isDkgResultValid", + } { + expectedSelector := functionSelector( + method + "(" + frostDkgResultTupleSignature + ")", + ) + actualSelector := walletRegistryABI.Methods[method].ID + if !bytes.Equal(actualSelector, expectedSelector) { + t.Fatalf( + "unexpected %s selector: got 0x%x, want 0x%x", + method, + actualSelector, + expectedSelector, + ) + } + } + + expectedEventID := crypto.Keccak256Hash([]byte( + "DkgResultSubmitted(bytes32,uint256," + + frostDkgResultTupleSignature + + ")", + )) + actualEventID := walletRegistryABI.Events["DkgResultSubmitted"].ID + if actualEventID != expectedEventID { + t.Fatalf( + "unexpected DkgResultSubmitted topic: got 0x%x, want 0x%x", + actualEventID, + expectedEventID, + ) + } + + validatorABI, err := frostvalidatorabi.FrostDkgValidatorMetaData.GetAbi() + if err != nil { + t.Fatal(err) + } + + expectedSelector := functionSelector( + "resultDigest(" + + frostDkgResultTupleSignature + + ",uint256,address,address)", + ) + actualSelector := validatorABI.Methods["resultDigest"].ID + if !bytes.Equal(actualSelector, expectedSelector) { + t.Fatalf( + "unexpected resultDigest selector: got 0x%x, want 0x%x", + actualSelector, + expectedSelector, + ) + } +} + +func assertStructFieldOrder( + t *testing.T, + structType reflect.Type, + expectedFields []string, +) { + t.Helper() + + if structType.NumField() != len(expectedFields) { + t.Fatalf( + "unexpected field count for %s: got %d, want %d", + structType.Name(), + structType.NumField(), + len(expectedFields), + ) + } + + for i, expectedField := range expectedFields { + if actualField := structType.Field(i).Name; actualField != expectedField { + t.Fatalf( + "unexpected field %d for %s: got %s, want %s", + i, + structType.Name(), + actualField, + expectedField, + ) + } + } +} + +func functionSelector(signature string) []byte { + hash := crypto.Keccak256([]byte(signature)) + return hash[:4] +} diff --git a/pkg/chain/ethereum/tbtc.go b/pkg/chain/ethereum/tbtc.go index 8af75a88ad..2a7e113a96 100644 --- a/pkg/chain/ethereum/tbtc.go +++ b/pkg/chain/ethereum/tbtc.go @@ -8,6 +8,7 @@ import ( "math/big" "reflect" "sort" + "strings" "time" "github.com/keep-network/keep-common/pkg/cache" @@ -52,6 +53,27 @@ const ( sweptDepositsCachePeriod = 7 * 24 * time.Hour ) +const frostWalletRegistryAuthorizationViewsABI = `[ + { + "inputs": [{"internalType": "address", "name": "operator", "type": "address"}], + "name": "operatorToStakingProvider", + "outputs": [{"internalType": "address", "name": "", "type": "address"}], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{"internalType": "address", "name": "stakingProvider", "type": "address"}], + "name": "eligibleStake", + "outputs": [{"internalType": "uint96", "name": "", "type": "uint96"}], + "stateMutability": "view", + "type": "function" + } +]` + +var frostWalletRegistryAuthorizationABI = mustParseABI( + frostWalletRegistryAuthorizationViewsABI, +) + // TbtcChain represents a TBTC-specific chain handle. type TbtcChain struct { *baseChain @@ -402,8 +424,9 @@ func (tc *TbtcChain) Staking() (chain.Address, error) { } // IsRecognized checks whether the given operator is recognized by the TbtcChain -// as eligible to join the network. If the operator has a stake delegation or -// had a stake delegation in the past, it will be recognized. +// as eligible to join the network. Legacy ECDSA operators are recognized if +// they have or had a stake delegation. FROST operators are recognized if the +// FROST registry maps them to a provider with non-zero eligible weight. func (tc *TbtcChain) IsRecognized(operatorPublicKey *operator.PublicKey) (bool, error) { operatorAddress, err := operatorPublicKeyToChainAddress(operatorPublicKey) if err != nil { @@ -424,28 +447,122 @@ func (tc *TbtcChain) IsRecognized(operatorPublicKey *operator.PublicKey) (bool, ) } + if (stakingProvider != common.Address{}) { + // Check if the staking provider has an owner. This check ensures that there + // is/was a stake delegation for the given staking provider. + _, _, _, hasStakeDelegation, err := tc.baseChain.RolesOf( + chain.Address(stakingProvider.Hex()), + ) + if err != nil { + return false, fmt.Errorf( + "failed to check stake delegation for staking provider [%v]: [%v]", + stakingProvider, + err, + ) + } + + if hasStakeDelegation { + return true, nil + } + } + + isRecognizedByFrost, err := tc.isRecognizedByFrostRegistry(operatorAddress) + if err != nil { + return false, err + } + if !isRecognizedByFrost { + return false, nil + } + + return true, nil +} + +func (tc *TbtcChain) isRecognizedByFrostRegistry( + operatorAddress common.Address, +) (bool, error) { + if tc.frostWalletRegistry == nil || (tc.frostWalletRegistryAddr == common.Address{}) { + return false, nil + } + + out, err := tc.callFrostRegistryAuthorizationView( + "operatorToStakingProvider", + operatorAddress, + ) + if err != nil { + return false, fmt.Errorf( + "failed to map FROST operator [%v] to a provider: [%v]", + operatorAddress, + err, + ) + } + if len(out) != 1 { + return false, fmt.Errorf( + "unexpected FROST operatorToStakingProvider result length [%v]", + len(out), + ) + } + + stakingProvider := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) if (stakingProvider == common.Address{}) { return false, nil } - // Check if the staking provider has an owner. This check ensures that there - // is/was a stake delegation for the given staking provider. - _, _, _, hasStakeDelegation, err := tc.baseChain.RolesOf( - chain.Address(stakingProvider.Hex()), + out, err = tc.callFrostRegistryAuthorizationView( + "eligibleStake", + stakingProvider, ) if err != nil { return false, fmt.Errorf( - "failed to check stake delegation for staking provider [%v]: [%v]", + "failed to get FROST eligible weight for provider [%v]: [%v]", stakingProvider, err, ) } + if len(out) != 1 { + return false, fmt.Errorf( + "unexpected FROST eligibleStake result length [%v]", + len(out), + ) + } - if !hasStakeDelegation { - return false, nil + eligibleWeight := *abi.ConvertType(out[0], new(*big.Int)).(**big.Int) + return eligibleWeight.Sign() > 0, nil +} + +func (tc *TbtcChain) callFrostRegistryAuthorizationView( + method string, + args ...interface{}, +) ([]interface{}, error) { + var out []interface{} + + contract := bind.NewBoundContract( + tc.frostWalletRegistryAddr, + frostWalletRegistryAuthorizationABI, + tc.baseChain.client, + nil, + nil, + ) + + err := contract.Call( + &bind.CallOpts{From: tc.key.Address}, + &out, + method, + args..., + ) + if err != nil { + return nil, err } - return true, nil + return out, nil +} + +func mustParseABI(rawABI string) abi.ABI { + parsed, err := abi.JSON(strings.NewReader(rawABI)) + if err != nil { + panic(err) + } + + return parsed } // OperatorToStakingProvider returns the staking provider address for the @@ -1388,6 +1505,75 @@ func (tc *TbtcChain) PastDepositRevealedEvents( return convertedEvents, err } +func (tc *TbtcChain) PastTaprootDepositRevealedEvents( + filter *tbtc.DepositRevealedEventFilter, +) ([]*tbtc.TaprootDepositRevealedEvent, error) { + var startBlock uint64 + var endBlock *uint64 + var depositor []common.Address + var walletPublicKeyHash [][20]byte + + if filter != nil { + startBlock = filter.StartBlock + endBlock = filter.EndBlock + + for _, d := range filter.Depositor { + depositor = append(depositor, common.HexToAddress(d.String())) + } + + walletPublicKeyHash = filter.WalletPublicKeyHash + } + + events, err := tc.bridge.PastTaprootDepositRevealedEvents( + startBlock, + endBlock, + depositor, + walletPublicKeyHash, + ) + if err != nil { + return nil, err + } + + convertedEvents := make([]*tbtc.TaprootDepositRevealedEvent, 0) + for _, event := range events { + var vault *chain.Address + if event.Vault != [20]byte{} { + v := chain.Address(event.Vault.Hex()) + vault = &v + } + + convertedEvent := &tbtc.TaprootDepositRevealedEvent{ + // We can map the event.FundingTxHash field directly to the + // bitcoin.Hash type. This is because event.FundingTxHash is + // a [32]byte type representing a hash in the bitcoin.InternalByteOrder, + // just as bitcoin.Hash assumes. + FundingTxHash: event.FundingTxHash, + FundingOutputIndex: event.FundingOutputIndex, + Depositor: chain.Address(event.Depositor.Hex()), + Amount: event.Amount, + BlindingFactor: event.BlindingFactor, + WalletPublicKeyHash: event.WalletPubKeyHash, + WalletXOnlyPublicKey: event.WalletXOnlyPublicKey, + RefundPublicKeyHash: event.RefundPubKeyHash, + RefundXOnlyPublicKey: event.RefundXOnlyPublicKey, + RefundLocktime: event.RefundLocktime, + Vault: vault, + BlockNumber: event.Raw.BlockNumber, + } + + convertedEvents = append(convertedEvents, convertedEvent) + } + + sort.SliceStable( + convertedEvents, + func(i, j int) bool { + return convertedEvents[i].BlockNumber < convertedEvents[j].BlockNumber + }, + ) + + return convertedEvents, err +} + func (tc *TbtcChain) PastRedemptionRequestedEvents( filter *tbtc.RedemptionRequestedEventFilter, ) ([]*tbtc.RedemptionRequestedEvent, error) { @@ -2414,6 +2600,58 @@ func (tc *TbtcChain) ValidateDepositSweepProposal( return nil } +func (tc *TbtcChain) ValidateTaprootDepositSweepProposal( + walletPublicKeyHash [20]byte, + proposal *tbtc.DepositSweepProposal, + depositsExtraInfo []struct { + *tbtc.Deposit + FundingTx *bitcoin.Transaction + }, +) error { + dei := make( + []tbtcabi.WalletProposalValidatorTaprootDepositExtraInfo, + len(depositsExtraInfo), + ) + for i, depositExtraInfo := range depositsExtraInfo { + fundingTx := tbtcabi.BitcoinTxInfo2{ + Version: depositExtraInfo.FundingTx.SerializeVersion(), + InputVector: depositExtraInfo.FundingTx.SerializeInputs(), + OutputVector: depositExtraInfo.FundingTx.SerializeOutputs(), + Locktime: depositExtraInfo.FundingTx.SerializeLocktime(), + } + + if !depositExtraInfo.Deposit.IsTaproot() { + return fmt.Errorf("deposit extra info [%v] is not Taproot-native", i) + } + + dei[i] = tbtcabi.WalletProposalValidatorTaprootDepositExtraInfo{ + FundingTx: fundingTx, + BlindingFactor: depositExtraInfo.Deposit.BlindingFactor, + WalletPubKeyHash: depositExtraInfo.Deposit.WalletPublicKeyHash, + WalletXOnlyPublicKey: *depositExtraInfo.Deposit.WalletXOnlyPublicKey, + RefundPubKeyHash: depositExtraInfo.Deposit.RefundPublicKeyHash, + RefundXOnlyPublicKey: *depositExtraInfo.Deposit.RefundXOnlyPublicKey, + RefundLocktime: depositExtraInfo.Deposit.RefundLocktime, + } + } + + valid, err := tc.walletProposalValidator.ValidateTaprootDepositSweepProposal( + convertDepositSweepProposalToAbiType(walletPublicKeyHash, proposal), + dei, + ) + if err != nil { + return fmt.Errorf("validation failed: [%v]", err) + } + + // Should never happen because `validateTaprootDepositSweepProposal` + // returns true or reverts (returns an error) but do the check just in case. + if !valid { + return fmt.Errorf("unexpected validation result") + } + + return nil +} + func (tc *TbtcChain) GetDepositSweepMaxSize() (uint16, error) { return tc.walletProposalValidator.DEPOSITSWEEPMAXSIZE() } diff --git a/pkg/chain/ethereum/tbtc/gen/abi/Bridge.go b/pkg/chain/ethereum/tbtc/gen/abi/Bridge.go index a862325a69..60d00d2955 100644 --- a/pkg/chain/ethereum/tbtc/gen/abi/Bridge.go +++ b/pkg/chain/ethereum/tbtc/gen/abi/Bridge.go @@ -46,13 +46,6 @@ type BitcoinTxProof struct { CoinbaseProof []byte } -// BitcoinTxRSVSignature is an auto generated low-level Go binding around an user-defined struct. -type BitcoinTxRSVSignature struct { - R [32]byte - S [32]byte - V uint8 -} - // BitcoinTxUTXO is an auto generated low-level Go binding around an user-defined struct. type BitcoinTxUTXO struct { TxHash [32]byte @@ -81,12 +74,16 @@ type DepositDepositRevealInfo struct { Vault common.Address } -// FraudFraudChallenge is an auto generated low-level Go binding around an user-defined struct. -type FraudFraudChallenge struct { - Challenger common.Address - DepositAmount *big.Int - ReportedAt uint32 - Resolved bool +// DepositTaprootDepositRevealInfo is an auto generated low-level Go binding around an user-defined struct. +type DepositTaprootDepositRevealInfo struct { + FundingOutputIndex uint32 + BlindingFactor [8]byte + WalletPubKeyHash [20]byte + WalletXOnlyPublicKey [32]byte + RefundPubKeyHash [20]byte + RefundXOnlyPublicKey [32]byte + RefundLocktime [4]byte + Vault common.Address } // MovingFundsMovedFundsSweepRequest is an auto generated low-level Go binding around an user-defined struct. @@ -121,7 +118,7 @@ type WalletsWallet struct { // BridgeMetaData contains all meta data concerning the Bridge contract. var BridgeMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"depositDustThreshold\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"depositTreasuryFeeDivisor\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"depositTxMaxFee\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"depositRevealAheadPeriod\",\"type\":\"uint32\"}],\"name\":\"DepositParametersUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"fundingTxHash\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"fundingOutputIndex\",\"type\":\"uint32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"depositor\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"amount\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"bytes8\",\"name\":\"blindingFactor\",\"type\":\"bytes8\"},{\"indexed\":true,\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"indexed\":false,\"internalType\":\"bytes20\",\"name\":\"refundPubKeyHash\",\"type\":\"bytes20\"},{\"indexed\":false,\"internalType\":\"bytes4\",\"name\":\"refundLocktime\",\"type\":\"bytes4\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"vault\",\"type\":\"address\"}],\"name\":\"DepositRevealed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newVault\",\"type\":\"address\"}],\"name\":\"DepositVaultFixed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"sweepTxHash\",\"type\":\"bytes32\"}],\"name\":\"DepositsSwept\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"sighash\",\"type\":\"bytes32\"}],\"name\":\"FraudChallengeDefeatTimedOut\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"sighash\",\"type\":\"bytes32\"}],\"name\":\"FraudChallengeDefeated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"sighash\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"name\":\"FraudChallengeSubmitted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"fraudChallengeDepositAmount\",\"type\":\"uint96\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"fraudChallengeDefeatTimeout\",\"type\":\"uint32\"},{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"fraudSlashingAmount\",\"type\":\"uint96\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"fraudNotifierRewardMultiplier\",\"type\":\"uint32\"}],\"name\":\"FraudParametersUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldGovernance\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newGovernance\",\"type\":\"address\"}],\"name\":\"GovernanceTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"movingFundsTxHash\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"movingFundsTxOutputIndex\",\"type\":\"uint32\"}],\"name\":\"MovedFundsSweepTimedOut\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"sweepTxHash\",\"type\":\"bytes32\"}],\"name\":\"MovedFundsSwept\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"}],\"name\":\"MovingFundsBelowDustReported\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"indexed\":false,\"internalType\":\"bytes20[]\",\"name\":\"targetWallets\",\"type\":\"bytes20[]\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"submitter\",\"type\":\"address\"}],\"name\":\"MovingFundsCommitmentSubmitted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"movingFundsTxHash\",\"type\":\"bytes32\"}],\"name\":\"MovingFundsCompleted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"movingFundsTxMaxTotalFee\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"movingFundsDustThreshold\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"movingFundsTimeoutResetDelay\",\"type\":\"uint32\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"movingFundsTimeout\",\"type\":\"uint32\"},{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"movingFundsTimeoutSlashingAmount\",\"type\":\"uint96\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"movingFundsTimeoutNotifierRewardMultiplier\",\"type\":\"uint32\"},{\"indexed\":false,\"internalType\":\"uint16\",\"name\":\"movingFundsCommitmentGasOffset\",\"type\":\"uint16\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"movedFundsSweepTxMaxTotalFee\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"movedFundsSweepTimeout\",\"type\":\"uint32\"},{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"movedFundsSweepTimeoutSlashingAmount\",\"type\":\"uint96\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"movedFundsSweepTimeoutNotifierRewardMultiplier\",\"type\":\"uint32\"}],\"name\":\"MovingFundsParametersUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"}],\"name\":\"MovingFundsTimedOut\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"}],\"name\":\"MovingFundsTimeoutReset\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"ecdsaWalletID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"}],\"name\":\"NewWalletRegistered\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"walletID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"ecdsaWalletID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"}],\"name\":\"NewWalletRegisteredV2\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[],\"name\":\"NewWalletRequested\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"rebateStaking\",\"type\":\"address\"}],\"name\":\"RebateStakingSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"redemptionDustThreshold\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"redemptionTreasuryFeeDivisor\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"redemptionTxMaxFee\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"redemptionTxMaxTotalFee\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"redemptionTimeout\",\"type\":\"uint32\"},{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"redemptionTimeoutSlashingAmount\",\"type\":\"uint96\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"redemptionTimeoutNotifierRewardMultiplier\",\"type\":\"uint32\"}],\"name\":\"RedemptionParametersUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"redeemerOutputScript\",\"type\":\"bytes\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"redeemer\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"requestedAmount\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"treasuryFee\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"txMaxFee\",\"type\":\"uint64\"}],\"name\":\"RedemptionRequested\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"redeemerOutputScript\",\"type\":\"bytes\"}],\"name\":\"RedemptionTimedOut\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"redemptionWatchtower\",\"type\":\"address\"}],\"name\":\"RedemptionWatchtowerSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"redemptionTxHash\",\"type\":\"bytes32\"}],\"name\":\"RedemptionsCompleted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"spvMaintainer\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"isTrusted\",\"type\":\"bool\"}],\"name\":\"SpvMaintainerStatusUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"treasury\",\"type\":\"address\"}],\"name\":\"TreasuryUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"vault\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"isTrusted\",\"type\":\"bool\"}],\"name\":\"VaultStatusUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"ecdsaWalletID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"}],\"name\":\"WalletClosed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"ecdsaWalletID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"}],\"name\":\"WalletClosing\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"ecdsaWalletID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"}],\"name\":\"WalletMovingFunds\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"walletCreationPeriod\",\"type\":\"uint32\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"walletCreationMinBtcBalance\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"walletCreationMaxBtcBalance\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"walletClosureMinBtcBalance\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"walletMaxAge\",\"type\":\"uint32\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"walletMaxBtcTransfer\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"walletClosingPeriod\",\"type\":\"uint32\"}],\"name\":\"WalletParametersUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"ecdsaWalletID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"}],\"name\":\"WalletTerminated\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"ecdsaWalletID\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"publicKeyX\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"publicKeyY\",\"type\":\"bytes32\"}],\"name\":\"__ecdsaWalletCreatedCallback\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"publicKeyX\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"publicKeyY\",\"type\":\"bytes32\"}],\"name\":\"__ecdsaWalletHeartbeatFailedCallback\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"activeWalletID\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"activeWalletPubKeyHash\",\"outputs\":[{\"internalType\":\"bytes20\",\"name\":\"\",\"type\":\"bytes20\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"contractReferences\",\"outputs\":[{\"internalType\":\"contractBank\",\"name\":\"bank\",\"type\":\"address\"},{\"internalType\":\"contractIRelay\",\"name\":\"relay\",\"type\":\"address\"},{\"internalType\":\"contractIWalletRegistry\",\"name\":\"ecdsaWalletRegistry\",\"type\":\"address\"},{\"internalType\":\"contractReimbursementPool\",\"name\":\"reimbursementPool\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"walletPublicKey\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"preimage\",\"type\":\"bytes\"},{\"internalType\":\"bool\",\"name\":\"witness\",\"type\":\"bool\"}],\"name\":\"defeatFraudChallenge\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"walletPublicKey\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"heartbeatMessage\",\"type\":\"bytes\"}],\"name\":\"defeatFraudChallengeWithHeartbeat\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"depositParameters\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"depositDustThreshold\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"depositTreasuryFeeDivisor\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"depositTxMaxFee\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"depositRevealAheadPeriod\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"}],\"name\":\"deposits\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"depositor\",\"type\":\"address\"},{\"internalType\":\"uint64\",\"name\":\"amount\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"revealedAt\",\"type\":\"uint32\"},{\"internalType\":\"address\",\"name\":\"vault\",\"type\":\"address\"},{\"internalType\":\"uint64\",\"name\":\"treasuryFee\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"sweptAt\",\"type\":\"uint32\"},{\"internalType\":\"bytes32\",\"name\":\"extraData\",\"type\":\"bytes32\"}],\"internalType\":\"structDeposit.DepositRequest\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"challengeKey\",\"type\":\"uint256\"}],\"name\":\"fraudChallenges\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"challenger\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"depositAmount\",\"type\":\"uint256\"},{\"internalType\":\"uint32\",\"name\":\"reportedAt\",\"type\":\"uint32\"},{\"internalType\":\"bool\",\"name\":\"resolved\",\"type\":\"bool\"}],\"internalType\":\"structFraud.FraudChallenge\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"fraudParameters\",\"outputs\":[{\"internalType\":\"uint96\",\"name\":\"fraudChallengeDepositAmount\",\"type\":\"uint96\"},{\"internalType\":\"uint32\",\"name\":\"fraudChallengeDefeatTimeout\",\"type\":\"uint32\"},{\"internalType\":\"uint96\",\"name\":\"fraudSlashingAmount\",\"type\":\"uint96\"},{\"internalType\":\"uint32\",\"name\":\"fraudNotifierRewardMultiplier\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getRebateStaking\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getRedemptionWatchtower\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"governance\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_bank\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_relay\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_treasury\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_ecdsaWalletRegistry\",\"type\":\"address\"},{\"internalType\":\"addresspayable\",\"name\":\"_reimbursementPool\",\"type\":\"address\"},{\"internalType\":\"uint96\",\"name\":\"_txProofDifficultyFactor\",\"type\":\"uint96\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"initializeV2_FixVaultZeroDeposit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"vault\",\"type\":\"address\"}],\"name\":\"isVaultTrusted\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"liveWalletsCount\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"requestKey\",\"type\":\"uint256\"}],\"name\":\"movedFundsSweepRequests\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"uint64\",\"name\":\"value\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"createdAt\",\"type\":\"uint32\"},{\"internalType\":\"enumMovingFunds.MovedFundsSweepRequestState\",\"name\":\"state\",\"type\":\"uint8\"}],\"internalType\":\"structMovingFunds.MovedFundsSweepRequest\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"movingFundsParameters\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"movingFundsTxMaxTotalFee\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"movingFundsDustThreshold\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"movingFundsTimeoutResetDelay\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"movingFundsTimeout\",\"type\":\"uint32\"},{\"internalType\":\"uint96\",\"name\":\"movingFundsTimeoutSlashingAmount\",\"type\":\"uint96\"},{\"internalType\":\"uint32\",\"name\":\"movingFundsTimeoutNotifierRewardMultiplier\",\"type\":\"uint32\"},{\"internalType\":\"uint16\",\"name\":\"movingFundsCommitmentGasOffset\",\"type\":\"uint16\"},{\"internalType\":\"uint64\",\"name\":\"movedFundsSweepTxMaxTotalFee\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"movedFundsSweepTimeout\",\"type\":\"uint32\"},{\"internalType\":\"uint96\",\"name\":\"movedFundsSweepTimeoutSlashingAmount\",\"type\":\"uint96\"},{\"internalType\":\"uint32\",\"name\":\"movedFundsSweepTimeoutNotifierRewardMultiplier\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"walletPublicKey\",\"type\":\"bytes\"},{\"internalType\":\"uint32[]\",\"name\":\"walletMembersIDs\",\"type\":\"uint32[]\"},{\"internalType\":\"bytes\",\"name\":\"preimageSha256\",\"type\":\"bytes\"}],\"name\":\"notifyFraudChallengeDefeatTimeout\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"movingFundsTxHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"movingFundsTxOutputIndex\",\"type\":\"uint32\"},{\"internalType\":\"uint32[]\",\"name\":\"walletMembersIDs\",\"type\":\"uint32[]\"}],\"name\":\"notifyMovedFundsSweepTimeout\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"txHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"txOutputIndex\",\"type\":\"uint32\"},{\"internalType\":\"uint64\",\"name\":\"txOutputValue\",\"type\":\"uint64\"}],\"internalType\":\"structBitcoinTx.UTXO\",\"name\":\"mainUtxo\",\"type\":\"tuple\"}],\"name\":\"notifyMovingFundsBelowDust\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"uint32[]\",\"name\":\"walletMembersIDs\",\"type\":\"uint32[]\"}],\"name\":\"notifyMovingFundsTimeout\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"uint32[]\",\"name\":\"walletMembersIDs\",\"type\":\"uint32[]\"},{\"internalType\":\"bytes\",\"name\":\"redeemerOutputScript\",\"type\":\"bytes\"}],\"name\":\"notifyRedemptionTimeout\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes\",\"name\":\"redeemerOutputScript\",\"type\":\"bytes\"}],\"name\":\"notifyRedemptionVeto\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"txHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"txOutputIndex\",\"type\":\"uint32\"},{\"internalType\":\"uint64\",\"name\":\"txOutputValue\",\"type\":\"uint64\"}],\"internalType\":\"structBitcoinTx.UTXO\",\"name\":\"walletMainUtxo\",\"type\":\"tuple\"}],\"name\":\"notifyWalletCloseable\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"}],\"name\":\"notifyWalletClosingPeriodElapsed\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"redemptionKey\",\"type\":\"uint256\"}],\"name\":\"pendingRedemptions\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"redeemer\",\"type\":\"address\"},{\"internalType\":\"uint64\",\"name\":\"requestedAmount\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"treasuryFee\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"txMaxFee\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"requestedAt\",\"type\":\"uint32\"}],\"internalType\":\"structRedemption.RedemptionRequest\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"balanceOwner\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"redemptionData\",\"type\":\"bytes\"}],\"name\":\"receiveBalanceApproval\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"redemptionParameters\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"redemptionDustThreshold\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"redemptionTreasuryFeeDivisor\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"redemptionTxMaxFee\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"redemptionTxMaxTotalFee\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"redemptionTimeout\",\"type\":\"uint32\"},{\"internalType\":\"uint96\",\"name\":\"redemptionTimeoutSlashingAmount\",\"type\":\"uint96\"},{\"internalType\":\"uint32\",\"name\":\"redemptionTimeoutNotifierRewardMultiplier\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"txHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"txOutputIndex\",\"type\":\"uint32\"},{\"internalType\":\"uint64\",\"name\":\"txOutputValue\",\"type\":\"uint64\"}],\"internalType\":\"structBitcoinTx.UTXO\",\"name\":\"activeWalletMainUtxo\",\"type\":\"tuple\"}],\"name\":\"requestNewWallet\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"txHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"txOutputIndex\",\"type\":\"uint32\"},{\"internalType\":\"uint64\",\"name\":\"txOutputValue\",\"type\":\"uint64\"}],\"internalType\":\"structBitcoinTx.UTXO\",\"name\":\"mainUtxo\",\"type\":\"tuple\"},{\"internalType\":\"bytes\",\"name\":\"redeemerOutputScript\",\"type\":\"bytes\"},{\"internalType\":\"uint64\",\"name\":\"amount\",\"type\":\"uint64\"}],\"name\":\"requestRedemption\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"}],\"name\":\"resetMovingFundsTimeout\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes4\",\"name\":\"version\",\"type\":\"bytes4\"},{\"internalType\":\"bytes\",\"name\":\"inputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"outputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes4\",\"name\":\"locktime\",\"type\":\"bytes4\"}],\"internalType\":\"structBitcoinTx.Info\",\"name\":\"fundingTx\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"uint32\",\"name\":\"fundingOutputIndex\",\"type\":\"uint32\"},{\"internalType\":\"bytes8\",\"name\":\"blindingFactor\",\"type\":\"bytes8\"},{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes20\",\"name\":\"refundPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes4\",\"name\":\"refundLocktime\",\"type\":\"bytes4\"},{\"internalType\":\"address\",\"name\":\"vault\",\"type\":\"address\"}],\"internalType\":\"structDeposit.DepositRevealInfo\",\"name\":\"reveal\",\"type\":\"tuple\"}],\"name\":\"revealDeposit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes4\",\"name\":\"version\",\"type\":\"bytes4\"},{\"internalType\":\"bytes\",\"name\":\"inputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"outputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes4\",\"name\":\"locktime\",\"type\":\"bytes4\"}],\"internalType\":\"structBitcoinTx.Info\",\"name\":\"fundingTx\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"uint32\",\"name\":\"fundingOutputIndex\",\"type\":\"uint32\"},{\"internalType\":\"bytes8\",\"name\":\"blindingFactor\",\"type\":\"bytes8\"},{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes20\",\"name\":\"refundPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes4\",\"name\":\"refundLocktime\",\"type\":\"bytes4\"},{\"internalType\":\"address\",\"name\":\"vault\",\"type\":\"address\"}],\"internalType\":\"structDeposit.DepositRevealInfo\",\"name\":\"reveal\",\"type\":\"tuple\"},{\"internalType\":\"bytes32\",\"name\":\"extraData\",\"type\":\"bytes32\"}],\"name\":\"revealDepositWithExtraData\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"rebateStaking\",\"type\":\"address\"}],\"name\":\"setRebateStaking\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"redemptionWatchtower\",\"type\":\"address\"}],\"name\":\"setRedemptionWatchtower\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spvMaintainer\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"isTrusted\",\"type\":\"bool\"}],\"name\":\"setSpvMaintainerStatus\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"vault\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"isTrusted\",\"type\":\"bool\"}],\"name\":\"setVaultStatus\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"utxoKey\",\"type\":\"uint256\"}],\"name\":\"spentMainUTXOs\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes4\",\"name\":\"version\",\"type\":\"bytes4\"},{\"internalType\":\"bytes\",\"name\":\"inputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"outputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes4\",\"name\":\"locktime\",\"type\":\"bytes4\"}],\"internalType\":\"structBitcoinTx.Info\",\"name\":\"sweepTx\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"bytes\",\"name\":\"merkleProof\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"txIndexInBlock\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"bitcoinHeaders\",\"type\":\"bytes\"},{\"internalType\":\"bytes32\",\"name\":\"coinbasePreimage\",\"type\":\"bytes32\"},{\"internalType\":\"bytes\",\"name\":\"coinbaseProof\",\"type\":\"bytes\"}],\"internalType\":\"structBitcoinTx.Proof\",\"name\":\"sweepProof\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"txHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"txOutputIndex\",\"type\":\"uint32\"},{\"internalType\":\"uint64\",\"name\":\"txOutputValue\",\"type\":\"uint64\"}],\"internalType\":\"structBitcoinTx.UTXO\",\"name\":\"mainUtxo\",\"type\":\"tuple\"},{\"internalType\":\"address\",\"name\":\"vault\",\"type\":\"address\"}],\"name\":\"submitDepositSweepProof\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes\",\"name\":\"walletPublicKey\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"preimageSha256\",\"type\":\"bytes\"},{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"}],\"internalType\":\"structBitcoinTx.RSVSignature\",\"name\":\"signature\",\"type\":\"tuple\"}],\"name\":\"submitFraudChallenge\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes4\",\"name\":\"version\",\"type\":\"bytes4\"},{\"internalType\":\"bytes\",\"name\":\"inputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"outputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes4\",\"name\":\"locktime\",\"type\":\"bytes4\"}],\"internalType\":\"structBitcoinTx.Info\",\"name\":\"sweepTx\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"bytes\",\"name\":\"merkleProof\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"txIndexInBlock\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"bitcoinHeaders\",\"type\":\"bytes\"},{\"internalType\":\"bytes32\",\"name\":\"coinbasePreimage\",\"type\":\"bytes32\"},{\"internalType\":\"bytes\",\"name\":\"coinbaseProof\",\"type\":\"bytes\"}],\"internalType\":\"structBitcoinTx.Proof\",\"name\":\"sweepProof\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"txHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"txOutputIndex\",\"type\":\"uint32\"},{\"internalType\":\"uint64\",\"name\":\"txOutputValue\",\"type\":\"uint64\"}],\"internalType\":\"structBitcoinTx.UTXO\",\"name\":\"mainUtxo\",\"type\":\"tuple\"}],\"name\":\"submitMovedFundsSweepProof\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"txHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"txOutputIndex\",\"type\":\"uint32\"},{\"internalType\":\"uint64\",\"name\":\"txOutputValue\",\"type\":\"uint64\"}],\"internalType\":\"structBitcoinTx.UTXO\",\"name\":\"walletMainUtxo\",\"type\":\"tuple\"},{\"internalType\":\"uint32[]\",\"name\":\"walletMembersIDs\",\"type\":\"uint32[]\"},{\"internalType\":\"uint256\",\"name\":\"walletMemberIndex\",\"type\":\"uint256\"},{\"internalType\":\"bytes20[]\",\"name\":\"targetWallets\",\"type\":\"bytes20[]\"}],\"name\":\"submitMovingFundsCommitment\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes4\",\"name\":\"version\",\"type\":\"bytes4\"},{\"internalType\":\"bytes\",\"name\":\"inputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"outputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes4\",\"name\":\"locktime\",\"type\":\"bytes4\"}],\"internalType\":\"structBitcoinTx.Info\",\"name\":\"movingFundsTx\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"bytes\",\"name\":\"merkleProof\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"txIndexInBlock\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"bitcoinHeaders\",\"type\":\"bytes\"},{\"internalType\":\"bytes32\",\"name\":\"coinbasePreimage\",\"type\":\"bytes32\"},{\"internalType\":\"bytes\",\"name\":\"coinbaseProof\",\"type\":\"bytes\"}],\"internalType\":\"structBitcoinTx.Proof\",\"name\":\"movingFundsProof\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"txHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"txOutputIndex\",\"type\":\"uint32\"},{\"internalType\":\"uint64\",\"name\":\"txOutputValue\",\"type\":\"uint64\"}],\"internalType\":\"structBitcoinTx.UTXO\",\"name\":\"mainUtxo\",\"type\":\"tuple\"},{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"}],\"name\":\"submitMovingFundsProof\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes4\",\"name\":\"version\",\"type\":\"bytes4\"},{\"internalType\":\"bytes\",\"name\":\"inputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"outputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes4\",\"name\":\"locktime\",\"type\":\"bytes4\"}],\"internalType\":\"structBitcoinTx.Info\",\"name\":\"redemptionTx\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"bytes\",\"name\":\"merkleProof\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"txIndexInBlock\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"bitcoinHeaders\",\"type\":\"bytes\"},{\"internalType\":\"bytes32\",\"name\":\"coinbasePreimage\",\"type\":\"bytes32\"},{\"internalType\":\"bytes\",\"name\":\"coinbaseProof\",\"type\":\"bytes\"}],\"internalType\":\"structBitcoinTx.Proof\",\"name\":\"redemptionProof\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"txHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"txOutputIndex\",\"type\":\"uint32\"},{\"internalType\":\"uint64\",\"name\":\"txOutputValue\",\"type\":\"uint64\"}],\"internalType\":\"structBitcoinTx.UTXO\",\"name\":\"mainUtxo\",\"type\":\"tuple\"},{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"}],\"name\":\"submitRedemptionProof\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"redemptionKey\",\"type\":\"uint256\"}],\"name\":\"timedOutRedemptions\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"redeemer\",\"type\":\"address\"},{\"internalType\":\"uint64\",\"name\":\"requestedAmount\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"treasuryFee\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"txMaxFee\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"requestedAt\",\"type\":\"uint32\"}],\"internalType\":\"structRedemption.RedemptionRequest\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newGovernance\",\"type\":\"address\"}],\"name\":\"transferGovernance\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"treasury\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"txProofDifficultyFactor\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"depositDustThreshold\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"depositTreasuryFeeDivisor\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"depositTxMaxFee\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"depositRevealAheadPeriod\",\"type\":\"uint32\"}],\"name\":\"updateDepositParameters\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint96\",\"name\":\"fraudChallengeDepositAmount\",\"type\":\"uint96\"},{\"internalType\":\"uint32\",\"name\":\"fraudChallengeDefeatTimeout\",\"type\":\"uint32\"},{\"internalType\":\"uint96\",\"name\":\"fraudSlashingAmount\",\"type\":\"uint96\"},{\"internalType\":\"uint32\",\"name\":\"fraudNotifierRewardMultiplier\",\"type\":\"uint32\"}],\"name\":\"updateFraudParameters\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"movingFundsTxMaxTotalFee\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"movingFundsDustThreshold\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"movingFundsTimeoutResetDelay\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"movingFundsTimeout\",\"type\":\"uint32\"},{\"internalType\":\"uint96\",\"name\":\"movingFundsTimeoutSlashingAmount\",\"type\":\"uint96\"},{\"internalType\":\"uint32\",\"name\":\"movingFundsTimeoutNotifierRewardMultiplier\",\"type\":\"uint32\"},{\"internalType\":\"uint16\",\"name\":\"movingFundsCommitmentGasOffset\",\"type\":\"uint16\"},{\"internalType\":\"uint64\",\"name\":\"movedFundsSweepTxMaxTotalFee\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"movedFundsSweepTimeout\",\"type\":\"uint32\"},{\"internalType\":\"uint96\",\"name\":\"movedFundsSweepTimeoutSlashingAmount\",\"type\":\"uint96\"},{\"internalType\":\"uint32\",\"name\":\"movedFundsSweepTimeoutNotifierRewardMultiplier\",\"type\":\"uint32\"}],\"name\":\"updateMovingFundsParameters\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"redemptionDustThreshold\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"redemptionTreasuryFeeDivisor\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"redemptionTxMaxFee\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"redemptionTxMaxTotalFee\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"redemptionTimeout\",\"type\":\"uint32\"},{\"internalType\":\"uint96\",\"name\":\"redemptionTimeoutSlashingAmount\",\"type\":\"uint96\"},{\"internalType\":\"uint32\",\"name\":\"redemptionTimeoutNotifierRewardMultiplier\",\"type\":\"uint32\"}],\"name\":\"updateRedemptionParameters\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"treasury\",\"type\":\"address\"}],\"name\":\"updateTreasury\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"walletCreationPeriod\",\"type\":\"uint32\"},{\"internalType\":\"uint64\",\"name\":\"walletCreationMinBtcBalance\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"walletCreationMaxBtcBalance\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"walletClosureMinBtcBalance\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"walletMaxAge\",\"type\":\"uint32\"},{\"internalType\":\"uint64\",\"name\":\"walletMaxBtcTransfer\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"walletClosingPeriod\",\"type\":\"uint32\"}],\"name\":\"updateWalletParameters\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"}],\"name\":\"walletID\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"pure\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"walletParameters\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"walletCreationPeriod\",\"type\":\"uint32\"},{\"internalType\":\"uint64\",\"name\":\"walletCreationMinBtcBalance\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"walletCreationMaxBtcBalance\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"walletClosureMinBtcBalance\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"walletMaxAge\",\"type\":\"uint32\"},{\"internalType\":\"uint64\",\"name\":\"walletMaxBtcTransfer\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"walletClosingPeriod\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"walletId\",\"type\":\"bytes32\"}],\"name\":\"walletPubKeyHashForWalletID\",\"outputs\":[{\"internalType\":\"bytes20\",\"name\":\"\",\"type\":\"bytes20\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"}],\"name\":\"wallets\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"ecdsaWalletID\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"mainUtxoHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint64\",\"name\":\"pendingRedemptionsValue\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"createdAt\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"movingFundsRequestedAt\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"closingStartedAt\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"pendingMovedFundsSweepRequestsCount\",\"type\":\"uint32\"},{\"internalType\":\"enumWallets.WalletState\",\"name\":\"state\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"movingFundsTargetWalletsCommitmentHash\",\"type\":\"bytes32\"}],\"internalType\":\"structWallets.Wallet\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"walletId\",\"type\":\"bytes32\"}],\"name\":\"walletsByWalletID\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"ecdsaWalletID\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"mainUtxoHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint64\",\"name\":\"pendingRedemptionsValue\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"createdAt\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"movingFundsRequestedAt\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"closingStartedAt\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"pendingMovedFundsSweepRequestsCount\",\"type\":\"uint32\"},{\"internalType\":\"enumWallets.WalletState\",\"name\":\"state\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"movingFundsTargetWalletsCommitmentHash\",\"type\":\"bytes32\"}],\"internalType\":\"structWallets.Wallet\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"AddressIsZero\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"EcdsaFraudRouterAddressZero\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"EcdsaFraudRouterAlreadySet\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"FrostWalletRegistryAddressZero\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"FrostWalletRegistryAlreadySet\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"LifecycleRouterAddressZero\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"LifecycleRouterAlreadySet\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"MigrateLegacyFraudChallengesNotImplemented\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"P2TRFraudRouterAddressZero\",\"type\":\"error\"},{\"inputs\":[],\"name\":\"P2TRFraudRouterAlreadySet\",\"type\":\"error\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"depositDustThreshold\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"depositTreasuryFeeDivisor\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"depositTxMaxFee\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"depositRevealAheadPeriod\",\"type\":\"uint32\"}],\"name\":\"DepositParametersUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"fundingTxHash\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"fundingOutputIndex\",\"type\":\"uint32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"depositor\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"amount\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"bytes8\",\"name\":\"blindingFactor\",\"type\":\"bytes8\"},{\"indexed\":true,\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"indexed\":false,\"internalType\":\"bytes20\",\"name\":\"refundPubKeyHash\",\"type\":\"bytes20\"},{\"indexed\":false,\"internalType\":\"bytes4\",\"name\":\"refundLocktime\",\"type\":\"bytes4\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"vault\",\"type\":\"address\"}],\"name\":\"DepositRevealed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newVault\",\"type\":\"address\"}],\"name\":\"DepositVaultFixed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"sweepTxHash\",\"type\":\"bytes32\"}],\"name\":\"DepositsSwept\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"ecdsaFraudRouter\",\"type\":\"address\"}],\"name\":\"EcdsaFraudRouterSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[],\"name\":\"EcdsaRetired\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"fraudChallengeDepositAmount\",\"type\":\"uint96\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"fraudChallengeDefeatTimeout\",\"type\":\"uint32\"},{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"fraudSlashingAmount\",\"type\":\"uint96\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"fraudNotifierRewardMultiplier\",\"type\":\"uint32\"}],\"name\":\"FraudParametersUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"frostWalletRegistry\",\"type\":\"address\"}],\"name\":\"FrostWalletRegistrySet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"oldGovernance\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"newGovernance\",\"type\":\"address\"}],\"name\":\"GovernanceTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"uint8\",\"name\":\"routerKind\",\"type\":\"uint8\"},{\"indexed\":true,\"internalType\":\"uint256\",\"name\":\"challengeKey\",\"type\":\"uint256\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"challenger\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"depositAmount\",\"type\":\"uint256\"}],\"name\":\"LegacyFraudChallengeMigrated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"lifecycleRouter\",\"type\":\"address\"}],\"name\":\"LifecycleRouterSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"movingFundsTxHash\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"movingFundsTxOutputIndex\",\"type\":\"uint32\"}],\"name\":\"MovedFundsSweepTimedOut\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"sweepTxHash\",\"type\":\"bytes32\"}],\"name\":\"MovedFundsSwept\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"}],\"name\":\"MovingFundsBelowDustReported\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"indexed\":false,\"internalType\":\"bytes20[]\",\"name\":\"targetWallets\",\"type\":\"bytes20[]\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"submitter\",\"type\":\"address\"}],\"name\":\"MovingFundsCommitmentSubmitted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"movingFundsTxHash\",\"type\":\"bytes32\"}],\"name\":\"MovingFundsCompleted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"movingFundsTxMaxTotalFee\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"movingFundsDustThreshold\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"movingFundsTimeoutResetDelay\",\"type\":\"uint32\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"movingFundsTimeout\",\"type\":\"uint32\"},{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"movingFundsTimeoutSlashingAmount\",\"type\":\"uint96\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"movingFundsTimeoutNotifierRewardMultiplier\",\"type\":\"uint32\"},{\"indexed\":false,\"internalType\":\"uint16\",\"name\":\"movingFundsCommitmentGasOffset\",\"type\":\"uint16\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"movedFundsSweepTxMaxTotalFee\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"movedFundsSweepTimeout\",\"type\":\"uint32\"},{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"movedFundsSweepTimeoutSlashingAmount\",\"type\":\"uint96\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"movedFundsSweepTimeoutNotifierRewardMultiplier\",\"type\":\"uint32\"}],\"name\":\"MovingFundsParametersUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"}],\"name\":\"MovingFundsTimedOut\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"}],\"name\":\"MovingFundsTimeoutReset\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"walletID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"xOnlyOutputKey\",\"type\":\"bytes32\"}],\"name\":\"NewFrostWalletRegistered\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"ecdsaWalletID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"}],\"name\":\"NewWalletRegistered\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"walletID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"ecdsaWalletID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"}],\"name\":\"NewWalletRegisteredV2\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[],\"name\":\"NewWalletRequested\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"enumBridgeState.WalletScheme\",\"name\":\"scheme\",\"type\":\"uint8\"}],\"name\":\"NewWalletSchemeSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"p2trFraudRouter\",\"type\":\"address\"}],\"name\":\"P2TRFraudRouterSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"rebateStaking\",\"type\":\"address\"}],\"name\":\"RebateStakingSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"redemptionDustThreshold\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"redemptionTreasuryFeeDivisor\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"redemptionTxMaxFee\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"redemptionTxMaxTotalFee\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"redemptionTimeout\",\"type\":\"uint32\"},{\"indexed\":false,\"internalType\":\"uint96\",\"name\":\"redemptionTimeoutSlashingAmount\",\"type\":\"uint96\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"redemptionTimeoutNotifierRewardMultiplier\",\"type\":\"uint32\"}],\"name\":\"RedemptionParametersUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"redeemerOutputScript\",\"type\":\"bytes\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"redeemer\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"requestedAmount\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"treasuryFee\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"txMaxFee\",\"type\":\"uint64\"}],\"name\":\"RedemptionRequested\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"redeemerOutputScript\",\"type\":\"bytes\"}],\"name\":\"RedemptionTimedOut\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"redemptionWatchtower\",\"type\":\"address\"}],\"name\":\"RedemptionWatchtowerSet\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"redemptionTxHash\",\"type\":\"bytes32\"}],\"name\":\"RedemptionsCompleted\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"spvMaintainer\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"isTrusted\",\"type\":\"bool\"}],\"name\":\"SpvMaintainerStatusUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"fundingTxHash\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"fundingOutputIndex\",\"type\":\"uint32\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"depositor\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"amount\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"bytes8\",\"name\":\"blindingFactor\",\"type\":\"bytes8\"},{\"indexed\":true,\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"walletXOnlyPublicKey\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"bytes20\",\"name\":\"refundPubKeyHash\",\"type\":\"bytes20\"},{\"indexed\":false,\"internalType\":\"bytes32\",\"name\":\"refundXOnlyPublicKey\",\"type\":\"bytes32\"},{\"indexed\":false,\"internalType\":\"bytes4\",\"name\":\"refundLocktime\",\"type\":\"bytes4\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"vault\",\"type\":\"address\"}],\"name\":\"TaprootDepositRevealed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"address\",\"name\":\"treasury\",\"type\":\"address\"}],\"name\":\"TreasuryUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"vault\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"bool\",\"name\":\"isTrusted\",\"type\":\"bool\"}],\"name\":\"VaultStatusUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"ecdsaWalletID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"}],\"name\":\"WalletClosed\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"ecdsaWalletID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"}],\"name\":\"WalletClosing\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"ecdsaWalletID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"}],\"name\":\"WalletMovingFunds\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"walletCreationPeriod\",\"type\":\"uint32\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"walletCreationMinBtcBalance\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"walletCreationMaxBtcBalance\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"walletClosureMinBtcBalance\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"walletMaxAge\",\"type\":\"uint32\"},{\"indexed\":false,\"internalType\":\"uint64\",\"name\":\"walletMaxBtcTransfer\",\"type\":\"uint64\"},{\"indexed\":false,\"internalType\":\"uint32\",\"name\":\"walletClosingPeriod\",\"type\":\"uint32\"}],\"name\":\"WalletParametersUpdated\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"bytes32\",\"name\":\"ecdsaWalletID\",\"type\":\"bytes32\"},{\"indexed\":true,\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"}],\"name\":\"WalletTerminated\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"publicKeyX\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"publicKeyY\",\"type\":\"bytes32\"}],\"name\":\"__ecdsaWalletHeartbeatFailedCallback\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"xOnlyOutputKey\",\"type\":\"bytes32\"}],\"name\":\"__frostWalletCreatedCallback\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"activeWalletID\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"activeWalletPubKeyHash\",\"outputs\":[{\"internalType\":\"bytes20\",\"name\":\"\",\"type\":\"bytes20\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"contractReferences\",\"outputs\":[{\"internalType\":\"contractBank\",\"name\":\"bank\",\"type\":\"address\"},{\"internalType\":\"contractIRelay\",\"name\":\"relay\",\"type\":\"address\"},{\"internalType\":\"contractIWalletRegistry\",\"name\":\"ecdsaWalletRegistry\",\"type\":\"address\"},{\"internalType\":\"contractReimbursementPool\",\"name\":\"reimbursementPool\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"depositParameters\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"depositDustThreshold\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"depositTreasuryFeeDivisor\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"depositTxMaxFee\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"depositRevealAheadPeriod\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"depositKey\",\"type\":\"uint256\"}],\"name\":\"deposits\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"depositor\",\"type\":\"address\"},{\"internalType\":\"uint64\",\"name\":\"amount\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"revealedAt\",\"type\":\"uint32\"},{\"internalType\":\"address\",\"name\":\"vault\",\"type\":\"address\"},{\"internalType\":\"uint64\",\"name\":\"treasuryFee\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"sweptAt\",\"type\":\"uint32\"},{\"internalType\":\"bytes32\",\"name\":\"extraData\",\"type\":\"bytes32\"}],\"internalType\":\"structDeposit.DepositRequest\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ecdsaFraudRouter\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ecdsaRetired\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"fraudParameters\",\"outputs\":[{\"internalType\":\"uint96\",\"name\":\"fraudChallengeDepositAmount\",\"type\":\"uint96\"},{\"internalType\":\"uint32\",\"name\":\"fraudChallengeDefeatTimeout\",\"type\":\"uint32\"},{\"internalType\":\"uint96\",\"name\":\"fraudSlashingAmount\",\"type\":\"uint96\"},{\"internalType\":\"uint32\",\"name\":\"fraudNotifierRewardMultiplier\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"}],\"name\":\"frostLifecycleContext\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"frostRegistry\",\"type\":\"address\"},{\"internalType\":\"bytes32\",\"name\":\"walletID\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getRebateStaking\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"getRedemptionWatchtower\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"governance\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_bank\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_relay\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_treasury\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_ecdsaWalletRegistry\",\"type\":\"address\"},{\"internalType\":\"addresspayable\",\"name\":\"_reimbursementPool\",\"type\":\"address\"},{\"internalType\":\"uint96\",\"name\":\"_txProofDifficultyFactor\",\"type\":\"uint96\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"initializeV2_FixVaultZeroDeposit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"vault\",\"type\":\"address\"}],\"name\":\"isVaultTrusted\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"liveWalletsCount\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"routerKind\",\"type\":\"uint8\"},{\"internalType\":\"uint256[]\",\"name\":\"challengeKeys\",\"type\":\"uint256[]\"}],\"name\":\"migrateLegacyFraudChallenges\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"requestKey\",\"type\":\"uint256\"}],\"name\":\"movedFundsSweepRequests\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"uint64\",\"name\":\"value\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"createdAt\",\"type\":\"uint32\"},{\"internalType\":\"enumMovingFunds.MovedFundsSweepRequestState\",\"name\":\"state\",\"type\":\"uint8\"}],\"internalType\":\"structMovingFunds.MovedFundsSweepRequest\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"movingFundsParameters\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"movingFundsTxMaxTotalFee\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"movingFundsDustThreshold\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"movingFundsTimeoutResetDelay\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"movingFundsTimeout\",\"type\":\"uint32\"},{\"internalType\":\"uint96\",\"name\":\"movingFundsTimeoutSlashingAmount\",\"type\":\"uint96\"},{\"internalType\":\"uint32\",\"name\":\"movingFundsTimeoutNotifierRewardMultiplier\",\"type\":\"uint32\"},{\"internalType\":\"uint16\",\"name\":\"movingFundsCommitmentGasOffset\",\"type\":\"uint16\"},{\"internalType\":\"uint64\",\"name\":\"movedFundsSweepTxMaxTotalFee\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"movedFundsSweepTimeout\",\"type\":\"uint32\"},{\"internalType\":\"uint96\",\"name\":\"movedFundsSweepTimeoutSlashingAmount\",\"type\":\"uint96\"},{\"internalType\":\"uint32\",\"name\":\"movedFundsSweepTimeoutNotifierRewardMultiplier\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"movingFundsTxHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"movingFundsTxOutputIndex\",\"type\":\"uint32\"},{\"internalType\":\"uint32[]\",\"name\":\"walletMembersIDs\",\"type\":\"uint32[]\"}],\"name\":\"notifyMovedFundsSweepTimeout\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"txHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"txOutputIndex\",\"type\":\"uint32\"},{\"internalType\":\"uint64\",\"name\":\"txOutputValue\",\"type\":\"uint64\"}],\"internalType\":\"structBitcoinTx.UTXO\",\"name\":\"mainUtxo\",\"type\":\"tuple\"}],\"name\":\"notifyMovingFundsBelowDust\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"uint32[]\",\"name\":\"walletMembersIDs\",\"type\":\"uint32[]\"}],\"name\":\"notifyMovingFundsTimeout\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"uint32[]\",\"name\":\"walletMembersIDs\",\"type\":\"uint32[]\"},{\"internalType\":\"bytes\",\"name\":\"redeemerOutputScript\",\"type\":\"bytes\"}],\"name\":\"notifyRedemptionTimeout\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes\",\"name\":\"redeemerOutputScript\",\"type\":\"bytes\"}],\"name\":\"notifyRedemptionVeto\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"txHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"txOutputIndex\",\"type\":\"uint32\"},{\"internalType\":\"uint64\",\"name\":\"txOutputValue\",\"type\":\"uint64\"}],\"internalType\":\"structBitcoinTx.UTXO\",\"name\":\"walletMainUtxo\",\"type\":\"tuple\"}],\"name\":\"notifyWalletCloseable\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"}],\"name\":\"notifyWalletClosingPeriodElapsed\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"p2trFraudRouter\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"redemptionKey\",\"type\":\"uint256\"}],\"name\":\"pendingRedemptions\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"redeemer\",\"type\":\"address\"},{\"internalType\":\"uint64\",\"name\":\"requestedAmount\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"treasuryFee\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"txMaxFee\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"requestedAt\",\"type\":\"uint32\"}],\"internalType\":\"structRedemption.RedemptionRequest\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"balanceOwner\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"redemptionData\",\"type\":\"bytes\"}],\"name\":\"receiveBalanceApproval\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"redemptionParameters\",\"outputs\":[{\"internalType\":\"uint64\",\"name\":\"redemptionDustThreshold\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"redemptionTreasuryFeeDivisor\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"redemptionTxMaxFee\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"redemptionTxMaxTotalFee\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"redemptionTimeout\",\"type\":\"uint32\"},{\"internalType\":\"uint96\",\"name\":\"redemptionTimeoutSlashingAmount\",\"type\":\"uint96\"},{\"internalType\":\"uint32\",\"name\":\"redemptionTimeoutNotifierRewardMultiplier\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"txHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"txOutputIndex\",\"type\":\"uint32\"},{\"internalType\":\"uint64\",\"name\":\"txOutputValue\",\"type\":\"uint64\"}],\"internalType\":\"structBitcoinTx.UTXO\",\"name\":\"activeWalletMainUtxo\",\"type\":\"tuple\"}],\"name\":\"requestNewWallet\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"txHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"txOutputIndex\",\"type\":\"uint32\"},{\"internalType\":\"uint64\",\"name\":\"txOutputValue\",\"type\":\"uint64\"}],\"internalType\":\"structBitcoinTx.UTXO\",\"name\":\"mainUtxo\",\"type\":\"tuple\"},{\"internalType\":\"bytes\",\"name\":\"redeemerOutputScript\",\"type\":\"bytes\"},{\"internalType\":\"uint64\",\"name\":\"amount\",\"type\":\"uint64\"}],\"name\":\"requestRedemption\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"}],\"name\":\"resetMovingFundsTimeout\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"retireEcdsa\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes4\",\"name\":\"version\",\"type\":\"bytes4\"},{\"internalType\":\"bytes\",\"name\":\"inputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"outputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes4\",\"name\":\"locktime\",\"type\":\"bytes4\"}],\"internalType\":\"structBitcoinTx.Info\",\"name\":\"fundingTx\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"uint32\",\"name\":\"fundingOutputIndex\",\"type\":\"uint32\"},{\"internalType\":\"bytes8\",\"name\":\"blindingFactor\",\"type\":\"bytes8\"},{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes20\",\"name\":\"refundPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes4\",\"name\":\"refundLocktime\",\"type\":\"bytes4\"},{\"internalType\":\"address\",\"name\":\"vault\",\"type\":\"address\"}],\"internalType\":\"structDeposit.DepositRevealInfo\",\"name\":\"reveal\",\"type\":\"tuple\"}],\"name\":\"revealDeposit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes4\",\"name\":\"version\",\"type\":\"bytes4\"},{\"internalType\":\"bytes\",\"name\":\"inputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"outputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes4\",\"name\":\"locktime\",\"type\":\"bytes4\"}],\"internalType\":\"structBitcoinTx.Info\",\"name\":\"fundingTx\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"uint32\",\"name\":\"fundingOutputIndex\",\"type\":\"uint32\"},{\"internalType\":\"bytes8\",\"name\":\"blindingFactor\",\"type\":\"bytes8\"},{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes20\",\"name\":\"refundPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes4\",\"name\":\"refundLocktime\",\"type\":\"bytes4\"},{\"internalType\":\"address\",\"name\":\"vault\",\"type\":\"address\"}],\"internalType\":\"structDeposit.DepositRevealInfo\",\"name\":\"reveal\",\"type\":\"tuple\"},{\"internalType\":\"bytes32\",\"name\":\"extraData\",\"type\":\"bytes32\"}],\"name\":\"revealDepositWithExtraData\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes4\",\"name\":\"version\",\"type\":\"bytes4\"},{\"internalType\":\"bytes\",\"name\":\"inputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"outputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes4\",\"name\":\"locktime\",\"type\":\"bytes4\"}],\"internalType\":\"structBitcoinTx.Info\",\"name\":\"fundingTx\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"uint32\",\"name\":\"fundingOutputIndex\",\"type\":\"uint32\"},{\"internalType\":\"bytes8\",\"name\":\"blindingFactor\",\"type\":\"bytes8\"},{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes32\",\"name\":\"walletXOnlyPublicKey\",\"type\":\"bytes32\"},{\"internalType\":\"bytes20\",\"name\":\"refundPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes32\",\"name\":\"refundXOnlyPublicKey\",\"type\":\"bytes32\"},{\"internalType\":\"bytes4\",\"name\":\"refundLocktime\",\"type\":\"bytes4\"},{\"internalType\":\"address\",\"name\":\"vault\",\"type\":\"address\"}],\"internalType\":\"structDeposit.TaprootDepositRevealInfo\",\"name\":\"reveal\",\"type\":\"tuple\"}],\"name\":\"revealTaprootDeposit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes4\",\"name\":\"version\",\"type\":\"bytes4\"},{\"internalType\":\"bytes\",\"name\":\"inputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"outputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes4\",\"name\":\"locktime\",\"type\":\"bytes4\"}],\"internalType\":\"structBitcoinTx.Info\",\"name\":\"fundingTx\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"uint32\",\"name\":\"fundingOutputIndex\",\"type\":\"uint32\"},{\"internalType\":\"bytes8\",\"name\":\"blindingFactor\",\"type\":\"bytes8\"},{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes32\",\"name\":\"walletXOnlyPublicKey\",\"type\":\"bytes32\"},{\"internalType\":\"bytes20\",\"name\":\"refundPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes32\",\"name\":\"refundXOnlyPublicKey\",\"type\":\"bytes32\"},{\"internalType\":\"bytes4\",\"name\":\"refundLocktime\",\"type\":\"bytes4\"},{\"internalType\":\"address\",\"name\":\"vault\",\"type\":\"address\"}],\"internalType\":\"structDeposit.TaprootDepositRevealInfo\",\"name\":\"reveal\",\"type\":\"tuple\"},{\"internalType\":\"bytes32\",\"name\":\"extraData\",\"type\":\"bytes32\"}],\"name\":\"revealTaprootDepositWithExtraData\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"ecdsaFraudRouter\",\"type\":\"address\"}],\"name\":\"setEcdsaFraudRouter\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"frostWalletRegistry\",\"type\":\"address\"}],\"name\":\"setFrostWalletRegistry\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"lifecycleRouter\",\"type\":\"address\"}],\"name\":\"setLifecycleRouter\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"p2trFraudRouter\",\"type\":\"address\"}],\"name\":\"setP2TRFraudRouter\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"rebateStaking\",\"type\":\"address\"}],\"name\":\"setRebateStaking\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"redemptionWatchtower\",\"type\":\"address\"}],\"name\":\"setRedemptionWatchtower\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spvMaintainer\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"isTrusted\",\"type\":\"bool\"}],\"name\":\"setSpvMaintainerStatus\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"vault\",\"type\":\"address\"},{\"internalType\":\"bool\",\"name\":\"isTrusted\",\"type\":\"bool\"}],\"name\":\"setVaultStatus\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"uint32[]\",\"name\":\"walletMembersIDs\",\"type\":\"uint32[]\"},{\"internalType\":\"address\",\"name\":\"challenger\",\"type\":\"address\"}],\"name\":\"slashWalletForFraud\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"uint32[]\",\"name\":\"walletMembersIDs\",\"type\":\"uint32[]\"},{\"internalType\":\"address\",\"name\":\"challenger\",\"type\":\"address\"}],\"name\":\"slashWalletForP2TRFraud\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"utxoKey\",\"type\":\"uint256\"}],\"name\":\"spentMainUTXOs\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes4\",\"name\":\"version\",\"type\":\"bytes4\"},{\"internalType\":\"bytes\",\"name\":\"inputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"outputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes4\",\"name\":\"locktime\",\"type\":\"bytes4\"}],\"internalType\":\"structBitcoinTx.Info\",\"name\":\"sweepTx\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"bytes\",\"name\":\"merkleProof\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"txIndexInBlock\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"bitcoinHeaders\",\"type\":\"bytes\"},{\"internalType\":\"bytes32\",\"name\":\"coinbasePreimage\",\"type\":\"bytes32\"},{\"internalType\":\"bytes\",\"name\":\"coinbaseProof\",\"type\":\"bytes\"}],\"internalType\":\"structBitcoinTx.Proof\",\"name\":\"sweepProof\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"txHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"txOutputIndex\",\"type\":\"uint32\"},{\"internalType\":\"uint64\",\"name\":\"txOutputValue\",\"type\":\"uint64\"}],\"internalType\":\"structBitcoinTx.UTXO\",\"name\":\"mainUtxo\",\"type\":\"tuple\"},{\"internalType\":\"address\",\"name\":\"vault\",\"type\":\"address\"}],\"name\":\"submitDepositSweepProof\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes4\",\"name\":\"version\",\"type\":\"bytes4\"},{\"internalType\":\"bytes\",\"name\":\"inputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"outputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes4\",\"name\":\"locktime\",\"type\":\"bytes4\"}],\"internalType\":\"structBitcoinTx.Info\",\"name\":\"sweepTx\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"bytes\",\"name\":\"merkleProof\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"txIndexInBlock\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"bitcoinHeaders\",\"type\":\"bytes\"},{\"internalType\":\"bytes32\",\"name\":\"coinbasePreimage\",\"type\":\"bytes32\"},{\"internalType\":\"bytes\",\"name\":\"coinbaseProof\",\"type\":\"bytes\"}],\"internalType\":\"structBitcoinTx.Proof\",\"name\":\"sweepProof\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"txHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"txOutputIndex\",\"type\":\"uint32\"},{\"internalType\":\"uint64\",\"name\":\"txOutputValue\",\"type\":\"uint64\"}],\"internalType\":\"structBitcoinTx.UTXO\",\"name\":\"mainUtxo\",\"type\":\"tuple\"}],\"name\":\"submitMovedFundsSweepProof\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"txHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"txOutputIndex\",\"type\":\"uint32\"},{\"internalType\":\"uint64\",\"name\":\"txOutputValue\",\"type\":\"uint64\"}],\"internalType\":\"structBitcoinTx.UTXO\",\"name\":\"walletMainUtxo\",\"type\":\"tuple\"},{\"internalType\":\"uint32[]\",\"name\":\"walletMembersIDs\",\"type\":\"uint32[]\"},{\"internalType\":\"uint256\",\"name\":\"walletMemberIndex\",\"type\":\"uint256\"},{\"internalType\":\"bytes20[]\",\"name\":\"targetWallets\",\"type\":\"bytes20[]\"}],\"name\":\"submitMovingFundsCommitment\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes4\",\"name\":\"version\",\"type\":\"bytes4\"},{\"internalType\":\"bytes\",\"name\":\"inputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"outputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes4\",\"name\":\"locktime\",\"type\":\"bytes4\"}],\"internalType\":\"structBitcoinTx.Info\",\"name\":\"movingFundsTx\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"bytes\",\"name\":\"merkleProof\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"txIndexInBlock\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"bitcoinHeaders\",\"type\":\"bytes\"},{\"internalType\":\"bytes32\",\"name\":\"coinbasePreimage\",\"type\":\"bytes32\"},{\"internalType\":\"bytes\",\"name\":\"coinbaseProof\",\"type\":\"bytes\"}],\"internalType\":\"structBitcoinTx.Proof\",\"name\":\"movingFundsProof\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"txHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"txOutputIndex\",\"type\":\"uint32\"},{\"internalType\":\"uint64\",\"name\":\"txOutputValue\",\"type\":\"uint64\"}],\"internalType\":\"structBitcoinTx.UTXO\",\"name\":\"mainUtxo\",\"type\":\"tuple\"},{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"}],\"name\":\"submitMovingFundsProof\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes4\",\"name\":\"version\",\"type\":\"bytes4\"},{\"internalType\":\"bytes\",\"name\":\"inputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"outputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes4\",\"name\":\"locktime\",\"type\":\"bytes4\"}],\"internalType\":\"structBitcoinTx.Info\",\"name\":\"redemptionTx\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"bytes\",\"name\":\"merkleProof\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"txIndexInBlock\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"bitcoinHeaders\",\"type\":\"bytes\"},{\"internalType\":\"bytes32\",\"name\":\"coinbasePreimage\",\"type\":\"bytes32\"},{\"internalType\":\"bytes\",\"name\":\"coinbaseProof\",\"type\":\"bytes\"}],\"internalType\":\"structBitcoinTx.Proof\",\"name\":\"redemptionProof\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"txHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"txOutputIndex\",\"type\":\"uint32\"},{\"internalType\":\"uint64\",\"name\":\"txOutputValue\",\"type\":\"uint64\"}],\"internalType\":\"structBitcoinTx.UTXO\",\"name\":\"mainUtxo\",\"type\":\"tuple\"},{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"}],\"name\":\"submitRedemptionProof\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"redemptionKey\",\"type\":\"uint256\"}],\"name\":\"timedOutRedemptions\",\"outputs\":[{\"components\":[{\"internalType\":\"address\",\"name\":\"redeemer\",\"type\":\"address\"},{\"internalType\":\"uint64\",\"name\":\"requestedAmount\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"treasuryFee\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"txMaxFee\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"requestedAt\",\"type\":\"uint32\"}],\"internalType\":\"structRedemption.RedemptionRequest\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newGovernance\",\"type\":\"address\"}],\"name\":\"transferGovernance\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"treasury\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"txProofDifficultyFactor\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"depositDustThreshold\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"depositTreasuryFeeDivisor\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"depositTxMaxFee\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"depositRevealAheadPeriod\",\"type\":\"uint32\"}],\"name\":\"updateDepositParameters\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint96\",\"name\":\"fraudChallengeDepositAmount\",\"type\":\"uint96\"},{\"internalType\":\"uint32\",\"name\":\"fraudChallengeDefeatTimeout\",\"type\":\"uint32\"},{\"internalType\":\"uint96\",\"name\":\"fraudSlashingAmount\",\"type\":\"uint96\"},{\"internalType\":\"uint32\",\"name\":\"fraudNotifierRewardMultiplier\",\"type\":\"uint32\"}],\"name\":\"updateFraudParameters\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"movingFundsTxMaxTotalFee\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"movingFundsDustThreshold\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"movingFundsTimeoutResetDelay\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"movingFundsTimeout\",\"type\":\"uint32\"},{\"internalType\":\"uint96\",\"name\":\"movingFundsTimeoutSlashingAmount\",\"type\":\"uint96\"},{\"internalType\":\"uint32\",\"name\":\"movingFundsTimeoutNotifierRewardMultiplier\",\"type\":\"uint32\"},{\"internalType\":\"uint16\",\"name\":\"movingFundsCommitmentGasOffset\",\"type\":\"uint16\"},{\"internalType\":\"uint64\",\"name\":\"movedFundsSweepTxMaxTotalFee\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"movedFundsSweepTimeout\",\"type\":\"uint32\"},{\"internalType\":\"uint96\",\"name\":\"movedFundsSweepTimeoutSlashingAmount\",\"type\":\"uint96\"},{\"internalType\":\"uint32\",\"name\":\"movedFundsSweepTimeoutNotifierRewardMultiplier\",\"type\":\"uint32\"}],\"name\":\"updateMovingFundsParameters\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint64\",\"name\":\"redemptionDustThreshold\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"redemptionTreasuryFeeDivisor\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"redemptionTxMaxFee\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"redemptionTxMaxTotalFee\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"redemptionTimeout\",\"type\":\"uint32\"},{\"internalType\":\"uint96\",\"name\":\"redemptionTimeoutSlashingAmount\",\"type\":\"uint96\"},{\"internalType\":\"uint32\",\"name\":\"redemptionTimeoutNotifierRewardMultiplier\",\"type\":\"uint32\"}],\"name\":\"updateRedemptionParameters\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"treasury\",\"type\":\"address\"}],\"name\":\"updateTreasury\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint32\",\"name\":\"walletCreationPeriod\",\"type\":\"uint32\"},{\"internalType\":\"uint64\",\"name\":\"walletCreationMinBtcBalance\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"walletCreationMaxBtcBalance\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"walletClosureMinBtcBalance\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"walletMaxAge\",\"type\":\"uint32\"},{\"internalType\":\"uint64\",\"name\":\"walletMaxBtcTransfer\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"walletClosingPeriod\",\"type\":\"uint32\"}],\"name\":\"updateWalletParameters\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"}],\"name\":\"walletID\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"walletParameters\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"walletCreationPeriod\",\"type\":\"uint32\"},{\"internalType\":\"uint64\",\"name\":\"walletCreationMinBtcBalance\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"walletCreationMaxBtcBalance\",\"type\":\"uint64\"},{\"internalType\":\"uint64\",\"name\":\"walletClosureMinBtcBalance\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"walletMaxAge\",\"type\":\"uint32\"},{\"internalType\":\"uint64\",\"name\":\"walletMaxBtcTransfer\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"walletClosingPeriod\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"walletId\",\"type\":\"bytes32\"}],\"name\":\"walletPubKeyHashForWalletID\",\"outputs\":[{\"internalType\":\"bytes20\",\"name\":\"\",\"type\":\"bytes20\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"}],\"name\":\"wallets\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"ecdsaWalletID\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"mainUtxoHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint64\",\"name\":\"pendingRedemptionsValue\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"createdAt\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"movingFundsRequestedAt\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"closingStartedAt\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"pendingMovedFundsSweepRequestsCount\",\"type\":\"uint32\"},{\"internalType\":\"enumWallets.WalletState\",\"name\":\"state\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"movingFundsTargetWalletsCommitmentHash\",\"type\":\"bytes32\"}],\"internalType\":\"structWallets.Wallet\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"bytes32\",\"name\":\"walletId\",\"type\":\"bytes32\"}],\"name\":\"walletsByWalletID\",\"outputs\":[{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"ecdsaWalletID\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"mainUtxoHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint64\",\"name\":\"pendingRedemptionsValue\",\"type\":\"uint64\"},{\"internalType\":\"uint32\",\"name\":\"createdAt\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"movingFundsRequestedAt\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"closingStartedAt\",\"type\":\"uint32\"},{\"internalType\":\"uint32\",\"name\":\"pendingMovedFundsSweepRequestsCount\",\"type\":\"uint32\"},{\"internalType\":\"enumWallets.WalletState\",\"name\":\"state\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"movingFundsTargetWalletsCommitmentHash\",\"type\":\"bytes32\"}],\"internalType\":\"structWallets.Wallet\",\"name\":\"\",\"type\":\"tuple\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", } // BridgeABI is the input ABI used to generate the binding from. @@ -473,35 +470,66 @@ func (_Bridge *BridgeCallerSession) Deposits(depositKey *big.Int) (DepositDeposi return _Bridge.Contract.Deposits(&_Bridge.CallOpts, depositKey) } -// FraudChallenges is a free data retrieval call binding the contract method 0x33e957cb. +// EcdsaFraudRouter is a free data retrieval call binding the contract method 0x9fa00083. +// +// Solidity: function ecdsaFraudRouter() view returns(address) +func (_Bridge *BridgeCaller) EcdsaFraudRouter(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _Bridge.contract.Call(opts, &out, "ecdsaFraudRouter") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// EcdsaFraudRouter is a free data retrieval call binding the contract method 0x9fa00083. +// +// Solidity: function ecdsaFraudRouter() view returns(address) +func (_Bridge *BridgeSession) EcdsaFraudRouter() (common.Address, error) { + return _Bridge.Contract.EcdsaFraudRouter(&_Bridge.CallOpts) +} + +// EcdsaFraudRouter is a free data retrieval call binding the contract method 0x9fa00083. +// +// Solidity: function ecdsaFraudRouter() view returns(address) +func (_Bridge *BridgeCallerSession) EcdsaFraudRouter() (common.Address, error) { + return _Bridge.Contract.EcdsaFraudRouter(&_Bridge.CallOpts) +} + +// EcdsaRetired is a free data retrieval call binding the contract method 0xea3257e3. // -// Solidity: function fraudChallenges(uint256 challengeKey) view returns((address,uint256,uint32,bool)) -func (_Bridge *BridgeCaller) FraudChallenges(opts *bind.CallOpts, challengeKey *big.Int) (FraudFraudChallenge, error) { +// Solidity: function ecdsaRetired() view returns(bool) +func (_Bridge *BridgeCaller) EcdsaRetired(opts *bind.CallOpts) (bool, error) { var out []interface{} - err := _Bridge.contract.Call(opts, &out, "fraudChallenges", challengeKey) + err := _Bridge.contract.Call(opts, &out, "ecdsaRetired") if err != nil { - return *new(FraudFraudChallenge), err + return *new(bool), err } - out0 := *abi.ConvertType(out[0], new(FraudFraudChallenge)).(*FraudFraudChallenge) + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) return out0, err } -// FraudChallenges is a free data retrieval call binding the contract method 0x33e957cb. +// EcdsaRetired is a free data retrieval call binding the contract method 0xea3257e3. // -// Solidity: function fraudChallenges(uint256 challengeKey) view returns((address,uint256,uint32,bool)) -func (_Bridge *BridgeSession) FraudChallenges(challengeKey *big.Int) (FraudFraudChallenge, error) { - return _Bridge.Contract.FraudChallenges(&_Bridge.CallOpts, challengeKey) +// Solidity: function ecdsaRetired() view returns(bool) +func (_Bridge *BridgeSession) EcdsaRetired() (bool, error) { + return _Bridge.Contract.EcdsaRetired(&_Bridge.CallOpts) } -// FraudChallenges is a free data retrieval call binding the contract method 0x33e957cb. +// EcdsaRetired is a free data retrieval call binding the contract method 0xea3257e3. // -// Solidity: function fraudChallenges(uint256 challengeKey) view returns((address,uint256,uint32,bool)) -func (_Bridge *BridgeCallerSession) FraudChallenges(challengeKey *big.Int) (FraudFraudChallenge, error) { - return _Bridge.Contract.FraudChallenges(&_Bridge.CallOpts, challengeKey) +// Solidity: function ecdsaRetired() view returns(bool) +func (_Bridge *BridgeCallerSession) EcdsaRetired() (bool, error) { + return _Bridge.Contract.EcdsaRetired(&_Bridge.CallOpts) } // FraudParameters is a free data retrieval call binding the contract method 0x75b922d1. @@ -559,6 +587,51 @@ func (_Bridge *BridgeCallerSession) FraudParameters() (struct { return _Bridge.Contract.FraudParameters(&_Bridge.CallOpts) } +// FrostLifecycleContext is a free data retrieval call binding the contract method 0xd0ebc637. +// +// Solidity: function frostLifecycleContext(bytes20 walletPubKeyHash) view returns(address frostRegistry, bytes32 walletID) +func (_Bridge *BridgeCaller) FrostLifecycleContext(opts *bind.CallOpts, walletPubKeyHash [20]byte) (struct { + FrostRegistry common.Address + WalletID [32]byte +}, error) { + var out []interface{} + err := _Bridge.contract.Call(opts, &out, "frostLifecycleContext", walletPubKeyHash) + + outstruct := new(struct { + FrostRegistry common.Address + WalletID [32]byte + }) + if err != nil { + return *outstruct, err + } + + outstruct.FrostRegistry = *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + outstruct.WalletID = *abi.ConvertType(out[1], new([32]byte)).(*[32]byte) + + return *outstruct, err + +} + +// FrostLifecycleContext is a free data retrieval call binding the contract method 0xd0ebc637. +// +// Solidity: function frostLifecycleContext(bytes20 walletPubKeyHash) view returns(address frostRegistry, bytes32 walletID) +func (_Bridge *BridgeSession) FrostLifecycleContext(walletPubKeyHash [20]byte) (struct { + FrostRegistry common.Address + WalletID [32]byte +}, error) { + return _Bridge.Contract.FrostLifecycleContext(&_Bridge.CallOpts, walletPubKeyHash) +} + +// FrostLifecycleContext is a free data retrieval call binding the contract method 0xd0ebc637. +// +// Solidity: function frostLifecycleContext(bytes20 walletPubKeyHash) view returns(address frostRegistry, bytes32 walletID) +func (_Bridge *BridgeCallerSession) FrostLifecycleContext(walletPubKeyHash [20]byte) (struct { + FrostRegistry common.Address + WalletID [32]byte +}, error) { + return _Bridge.Contract.FrostLifecycleContext(&_Bridge.CallOpts, walletPubKeyHash) +} + // GetRebateStaking is a free data retrieval call binding the contract method 0x3edf8238. // // Solidity: function getRebateStaking() view returns(address) @@ -835,6 +908,37 @@ func (_Bridge *BridgeCallerSession) MovingFundsParameters() (struct { return _Bridge.Contract.MovingFundsParameters(&_Bridge.CallOpts) } +// P2trFraudRouter is a free data retrieval call binding the contract method 0xe3973b03. +// +// Solidity: function p2trFraudRouter() view returns(address) +func (_Bridge *BridgeCaller) P2trFraudRouter(opts *bind.CallOpts) (common.Address, error) { + var out []interface{} + err := _Bridge.contract.Call(opts, &out, "p2trFraudRouter") + + if err != nil { + return *new(common.Address), err + } + + out0 := *abi.ConvertType(out[0], new(common.Address)).(*common.Address) + + return out0, err + +} + +// P2trFraudRouter is a free data retrieval call binding the contract method 0xe3973b03. +// +// Solidity: function p2trFraudRouter() view returns(address) +func (_Bridge *BridgeSession) P2trFraudRouter() (common.Address, error) { + return _Bridge.Contract.P2trFraudRouter(&_Bridge.CallOpts) +} + +// P2trFraudRouter is a free data retrieval call binding the contract method 0xe3973b03. +// +// Solidity: function p2trFraudRouter() view returns(address) +func (_Bridge *BridgeCallerSession) P2trFraudRouter() (common.Address, error) { + return _Bridge.Contract.P2trFraudRouter(&_Bridge.CallOpts) +} + // PendingRedemptions is a free data retrieval call binding the contract method 0x03d952f7. // // Solidity: function pendingRedemptions(uint256 redemptionKey) view returns((address,uint64,uint64,uint64,uint32)) @@ -1062,7 +1166,7 @@ func (_Bridge *BridgeCallerSession) TxProofDifficultyFactor() (*big.Int, error) // WalletID is a free data retrieval call binding the contract method 0x858c14bd. // -// Solidity: function walletID(bytes20 walletPubKeyHash) pure returns(bytes32) +// Solidity: function walletID(bytes20 walletPubKeyHash) view returns(bytes32) func (_Bridge *BridgeCaller) WalletID(opts *bind.CallOpts, walletPubKeyHash [20]byte) ([32]byte, error) { var out []interface{} err := _Bridge.contract.Call(opts, &out, "walletID", walletPubKeyHash) @@ -1079,14 +1183,14 @@ func (_Bridge *BridgeCaller) WalletID(opts *bind.CallOpts, walletPubKeyHash [20] // WalletID is a free data retrieval call binding the contract method 0x858c14bd. // -// Solidity: function walletID(bytes20 walletPubKeyHash) pure returns(bytes32) +// Solidity: function walletID(bytes20 walletPubKeyHash) view returns(bytes32) func (_Bridge *BridgeSession) WalletID(walletPubKeyHash [20]byte) ([32]byte, error) { return _Bridge.Contract.WalletID(&_Bridge.CallOpts, walletPubKeyHash) } // WalletID is a free data retrieval call binding the contract method 0x858c14bd. // -// Solidity: function walletID(bytes20 walletPubKeyHash) pure returns(bytes32) +// Solidity: function walletID(bytes20 walletPubKeyHash) view returns(bytes32) func (_Bridge *BridgeCallerSession) WalletID(walletPubKeyHash [20]byte) ([32]byte, error) { return _Bridge.Contract.WalletID(&_Bridge.CallOpts, walletPubKeyHash) } @@ -1254,27 +1358,6 @@ func (_Bridge *BridgeCallerSession) WalletsByWalletID(walletId [32]byte) (Wallet return _Bridge.Contract.WalletsByWalletID(&_Bridge.CallOpts, walletId) } -// EcdsaWalletCreatedCallback is a paid mutator transaction binding the contract method 0xa8fa0f42. -// -// Solidity: function __ecdsaWalletCreatedCallback(bytes32 ecdsaWalletID, bytes32 publicKeyX, bytes32 publicKeyY) returns() -func (_Bridge *BridgeTransactor) EcdsaWalletCreatedCallback(opts *bind.TransactOpts, ecdsaWalletID [32]byte, publicKeyX [32]byte, publicKeyY [32]byte) (*types.Transaction, error) { - return _Bridge.contract.Transact(opts, "__ecdsaWalletCreatedCallback", ecdsaWalletID, publicKeyX, publicKeyY) -} - -// EcdsaWalletCreatedCallback is a paid mutator transaction binding the contract method 0xa8fa0f42. -// -// Solidity: function __ecdsaWalletCreatedCallback(bytes32 ecdsaWalletID, bytes32 publicKeyX, bytes32 publicKeyY) returns() -func (_Bridge *BridgeSession) EcdsaWalletCreatedCallback(ecdsaWalletID [32]byte, publicKeyX [32]byte, publicKeyY [32]byte) (*types.Transaction, error) { - return _Bridge.Contract.EcdsaWalletCreatedCallback(&_Bridge.TransactOpts, ecdsaWalletID, publicKeyX, publicKeyY) -} - -// EcdsaWalletCreatedCallback is a paid mutator transaction binding the contract method 0xa8fa0f42. -// -// Solidity: function __ecdsaWalletCreatedCallback(bytes32 ecdsaWalletID, bytes32 publicKeyX, bytes32 publicKeyY) returns() -func (_Bridge *BridgeTransactorSession) EcdsaWalletCreatedCallback(ecdsaWalletID [32]byte, publicKeyX [32]byte, publicKeyY [32]byte) (*types.Transaction, error) { - return _Bridge.Contract.EcdsaWalletCreatedCallback(&_Bridge.TransactOpts, ecdsaWalletID, publicKeyX, publicKeyY) -} - // EcdsaWalletHeartbeatFailedCallback is a paid mutator transaction binding the contract method 0x3dce9812. // // Solidity: function __ecdsaWalletHeartbeatFailedCallback(bytes32 , bytes32 publicKeyX, bytes32 publicKeyY) returns() @@ -1296,46 +1379,25 @@ func (_Bridge *BridgeTransactorSession) EcdsaWalletHeartbeatFailedCallback(arg0 return _Bridge.Contract.EcdsaWalletHeartbeatFailedCallback(&_Bridge.TransactOpts, arg0, publicKeyX, publicKeyY) } -// DefeatFraudChallenge is a paid mutator transaction binding the contract method 0x77145f21. -// -// Solidity: function defeatFraudChallenge(bytes walletPublicKey, bytes preimage, bool witness) returns() -func (_Bridge *BridgeTransactor) DefeatFraudChallenge(opts *bind.TransactOpts, walletPublicKey []byte, preimage []byte, witness bool) (*types.Transaction, error) { - return _Bridge.contract.Transact(opts, "defeatFraudChallenge", walletPublicKey, preimage, witness) -} - -// DefeatFraudChallenge is a paid mutator transaction binding the contract method 0x77145f21. +// FrostWalletCreatedCallback is a paid mutator transaction binding the contract method 0xd81c729e. // -// Solidity: function defeatFraudChallenge(bytes walletPublicKey, bytes preimage, bool witness) returns() -func (_Bridge *BridgeSession) DefeatFraudChallenge(walletPublicKey []byte, preimage []byte, witness bool) (*types.Transaction, error) { - return _Bridge.Contract.DefeatFraudChallenge(&_Bridge.TransactOpts, walletPublicKey, preimage, witness) +// Solidity: function __frostWalletCreatedCallback(bytes32 xOnlyOutputKey) returns() +func (_Bridge *BridgeTransactor) FrostWalletCreatedCallback(opts *bind.TransactOpts, xOnlyOutputKey [32]byte) (*types.Transaction, error) { + return _Bridge.contract.Transact(opts, "__frostWalletCreatedCallback", xOnlyOutputKey) } -// DefeatFraudChallenge is a paid mutator transaction binding the contract method 0x77145f21. +// FrostWalletCreatedCallback is a paid mutator transaction binding the contract method 0xd81c729e. // -// Solidity: function defeatFraudChallenge(bytes walletPublicKey, bytes preimage, bool witness) returns() -func (_Bridge *BridgeTransactorSession) DefeatFraudChallenge(walletPublicKey []byte, preimage []byte, witness bool) (*types.Transaction, error) { - return _Bridge.Contract.DefeatFraudChallenge(&_Bridge.TransactOpts, walletPublicKey, preimage, witness) +// Solidity: function __frostWalletCreatedCallback(bytes32 xOnlyOutputKey) returns() +func (_Bridge *BridgeSession) FrostWalletCreatedCallback(xOnlyOutputKey [32]byte) (*types.Transaction, error) { + return _Bridge.Contract.FrostWalletCreatedCallback(&_Bridge.TransactOpts, xOnlyOutputKey) } -// DefeatFraudChallengeWithHeartbeat is a paid mutator transaction binding the contract method 0x0674f266. +// FrostWalletCreatedCallback is a paid mutator transaction binding the contract method 0xd81c729e. // -// Solidity: function defeatFraudChallengeWithHeartbeat(bytes walletPublicKey, bytes heartbeatMessage) returns() -func (_Bridge *BridgeTransactor) DefeatFraudChallengeWithHeartbeat(opts *bind.TransactOpts, walletPublicKey []byte, heartbeatMessage []byte) (*types.Transaction, error) { - return _Bridge.contract.Transact(opts, "defeatFraudChallengeWithHeartbeat", walletPublicKey, heartbeatMessage) -} - -// DefeatFraudChallengeWithHeartbeat is a paid mutator transaction binding the contract method 0x0674f266. -// -// Solidity: function defeatFraudChallengeWithHeartbeat(bytes walletPublicKey, bytes heartbeatMessage) returns() -func (_Bridge *BridgeSession) DefeatFraudChallengeWithHeartbeat(walletPublicKey []byte, heartbeatMessage []byte) (*types.Transaction, error) { - return _Bridge.Contract.DefeatFraudChallengeWithHeartbeat(&_Bridge.TransactOpts, walletPublicKey, heartbeatMessage) -} - -// DefeatFraudChallengeWithHeartbeat is a paid mutator transaction binding the contract method 0x0674f266. -// -// Solidity: function defeatFraudChallengeWithHeartbeat(bytes walletPublicKey, bytes heartbeatMessage) returns() -func (_Bridge *BridgeTransactorSession) DefeatFraudChallengeWithHeartbeat(walletPublicKey []byte, heartbeatMessage []byte) (*types.Transaction, error) { - return _Bridge.Contract.DefeatFraudChallengeWithHeartbeat(&_Bridge.TransactOpts, walletPublicKey, heartbeatMessage) +// Solidity: function __frostWalletCreatedCallback(bytes32 xOnlyOutputKey) returns() +func (_Bridge *BridgeTransactorSession) FrostWalletCreatedCallback(xOnlyOutputKey [32]byte) (*types.Transaction, error) { + return _Bridge.Contract.FrostWalletCreatedCallback(&_Bridge.TransactOpts, xOnlyOutputKey) } // Initialize is a paid mutator transaction binding the contract method 0xd246ce16. @@ -1380,25 +1442,25 @@ func (_Bridge *BridgeTransactorSession) InitializeV2FixVaultZeroDeposit() (*type return _Bridge.Contract.InitializeV2FixVaultZeroDeposit(&_Bridge.TransactOpts) } -// NotifyFraudChallengeDefeatTimeout is a paid mutator transaction binding the contract method 0x79fc4eb3. +// MigrateLegacyFraudChallenges is a paid mutator transaction binding the contract method 0xfe491621. // -// Solidity: function notifyFraudChallengeDefeatTimeout(bytes walletPublicKey, uint32[] walletMembersIDs, bytes preimageSha256) returns() -func (_Bridge *BridgeTransactor) NotifyFraudChallengeDefeatTimeout(opts *bind.TransactOpts, walletPublicKey []byte, walletMembersIDs []uint32, preimageSha256 []byte) (*types.Transaction, error) { - return _Bridge.contract.Transact(opts, "notifyFraudChallengeDefeatTimeout", walletPublicKey, walletMembersIDs, preimageSha256) +// Solidity: function migrateLegacyFraudChallenges(uint8 routerKind, uint256[] challengeKeys) returns() +func (_Bridge *BridgeTransactor) MigrateLegacyFraudChallenges(opts *bind.TransactOpts, routerKind uint8, challengeKeys []*big.Int) (*types.Transaction, error) { + return _Bridge.contract.Transact(opts, "migrateLegacyFraudChallenges", routerKind, challengeKeys) } -// NotifyFraudChallengeDefeatTimeout is a paid mutator transaction binding the contract method 0x79fc4eb3. +// MigrateLegacyFraudChallenges is a paid mutator transaction binding the contract method 0xfe491621. // -// Solidity: function notifyFraudChallengeDefeatTimeout(bytes walletPublicKey, uint32[] walletMembersIDs, bytes preimageSha256) returns() -func (_Bridge *BridgeSession) NotifyFraudChallengeDefeatTimeout(walletPublicKey []byte, walletMembersIDs []uint32, preimageSha256 []byte) (*types.Transaction, error) { - return _Bridge.Contract.NotifyFraudChallengeDefeatTimeout(&_Bridge.TransactOpts, walletPublicKey, walletMembersIDs, preimageSha256) +// Solidity: function migrateLegacyFraudChallenges(uint8 routerKind, uint256[] challengeKeys) returns() +func (_Bridge *BridgeSession) MigrateLegacyFraudChallenges(routerKind uint8, challengeKeys []*big.Int) (*types.Transaction, error) { + return _Bridge.Contract.MigrateLegacyFraudChallenges(&_Bridge.TransactOpts, routerKind, challengeKeys) } -// NotifyFraudChallengeDefeatTimeout is a paid mutator transaction binding the contract method 0x79fc4eb3. +// MigrateLegacyFraudChallenges is a paid mutator transaction binding the contract method 0xfe491621. // -// Solidity: function notifyFraudChallengeDefeatTimeout(bytes walletPublicKey, uint32[] walletMembersIDs, bytes preimageSha256) returns() -func (_Bridge *BridgeTransactorSession) NotifyFraudChallengeDefeatTimeout(walletPublicKey []byte, walletMembersIDs []uint32, preimageSha256 []byte) (*types.Transaction, error) { - return _Bridge.Contract.NotifyFraudChallengeDefeatTimeout(&_Bridge.TransactOpts, walletPublicKey, walletMembersIDs, preimageSha256) +// Solidity: function migrateLegacyFraudChallenges(uint8 routerKind, uint256[] challengeKeys) returns() +func (_Bridge *BridgeTransactorSession) MigrateLegacyFraudChallenges(routerKind uint8, challengeKeys []*big.Int) (*types.Transaction, error) { + return _Bridge.Contract.MigrateLegacyFraudChallenges(&_Bridge.TransactOpts, routerKind, challengeKeys) } // NotifyMovedFundsSweepTimeout is a paid mutator transaction binding the contract method 0x50aea15a. @@ -1632,6 +1694,27 @@ func (_Bridge *BridgeTransactorSession) ResetMovingFundsTimeout(walletPubKeyHash return _Bridge.Contract.ResetMovingFundsTimeout(&_Bridge.TransactOpts, walletPubKeyHash) } +// RetireEcdsa is a paid mutator transaction binding the contract method 0x0652611e. +// +// Solidity: function retireEcdsa() returns() +func (_Bridge *BridgeTransactor) RetireEcdsa(opts *bind.TransactOpts) (*types.Transaction, error) { + return _Bridge.contract.Transact(opts, "retireEcdsa") +} + +// RetireEcdsa is a paid mutator transaction binding the contract method 0x0652611e. +// +// Solidity: function retireEcdsa() returns() +func (_Bridge *BridgeSession) RetireEcdsa() (*types.Transaction, error) { + return _Bridge.Contract.RetireEcdsa(&_Bridge.TransactOpts) +} + +// RetireEcdsa is a paid mutator transaction binding the contract method 0x0652611e. +// +// Solidity: function retireEcdsa() returns() +func (_Bridge *BridgeTransactorSession) RetireEcdsa() (*types.Transaction, error) { + return _Bridge.Contract.RetireEcdsa(&_Bridge.TransactOpts) +} + // RevealDeposit is a paid mutator transaction binding the contract method 0xfca4ba4c. // // Solidity: function revealDeposit((bytes4,bytes,bytes,bytes4) fundingTx, (uint32,bytes8,bytes20,bytes20,bytes4,address) reveal) returns() @@ -1674,6 +1757,132 @@ func (_Bridge *BridgeTransactorSession) RevealDepositWithExtraData(fundingTx Bit return _Bridge.Contract.RevealDepositWithExtraData(&_Bridge.TransactOpts, fundingTx, reveal, extraData) } +// RevealTaprootDeposit is a paid mutator transaction binding the contract method 0xbbbafefa. +// +// Solidity: function revealTaprootDeposit((bytes4,bytes,bytes,bytes4) fundingTx, (uint32,bytes8,bytes20,bytes32,bytes20,bytes32,bytes4,address) reveal) returns() +func (_Bridge *BridgeTransactor) RevealTaprootDeposit(opts *bind.TransactOpts, fundingTx BitcoinTxInfo, reveal DepositTaprootDepositRevealInfo) (*types.Transaction, error) { + return _Bridge.contract.Transact(opts, "revealTaprootDeposit", fundingTx, reveal) +} + +// RevealTaprootDeposit is a paid mutator transaction binding the contract method 0xbbbafefa. +// +// Solidity: function revealTaprootDeposit((bytes4,bytes,bytes,bytes4) fundingTx, (uint32,bytes8,bytes20,bytes32,bytes20,bytes32,bytes4,address) reveal) returns() +func (_Bridge *BridgeSession) RevealTaprootDeposit(fundingTx BitcoinTxInfo, reveal DepositTaprootDepositRevealInfo) (*types.Transaction, error) { + return _Bridge.Contract.RevealTaprootDeposit(&_Bridge.TransactOpts, fundingTx, reveal) +} + +// RevealTaprootDeposit is a paid mutator transaction binding the contract method 0xbbbafefa. +// +// Solidity: function revealTaprootDeposit((bytes4,bytes,bytes,bytes4) fundingTx, (uint32,bytes8,bytes20,bytes32,bytes20,bytes32,bytes4,address) reveal) returns() +func (_Bridge *BridgeTransactorSession) RevealTaprootDeposit(fundingTx BitcoinTxInfo, reveal DepositTaprootDepositRevealInfo) (*types.Transaction, error) { + return _Bridge.Contract.RevealTaprootDeposit(&_Bridge.TransactOpts, fundingTx, reveal) +} + +// RevealTaprootDepositWithExtraData is a paid mutator transaction binding the contract method 0xa97c9f34. +// +// Solidity: function revealTaprootDepositWithExtraData((bytes4,bytes,bytes,bytes4) fundingTx, (uint32,bytes8,bytes20,bytes32,bytes20,bytes32,bytes4,address) reveal, bytes32 extraData) returns() +func (_Bridge *BridgeTransactor) RevealTaprootDepositWithExtraData(opts *bind.TransactOpts, fundingTx BitcoinTxInfo, reveal DepositTaprootDepositRevealInfo, extraData [32]byte) (*types.Transaction, error) { + return _Bridge.contract.Transact(opts, "revealTaprootDepositWithExtraData", fundingTx, reveal, extraData) +} + +// RevealTaprootDepositWithExtraData is a paid mutator transaction binding the contract method 0xa97c9f34. +// +// Solidity: function revealTaprootDepositWithExtraData((bytes4,bytes,bytes,bytes4) fundingTx, (uint32,bytes8,bytes20,bytes32,bytes20,bytes32,bytes4,address) reveal, bytes32 extraData) returns() +func (_Bridge *BridgeSession) RevealTaprootDepositWithExtraData(fundingTx BitcoinTxInfo, reveal DepositTaprootDepositRevealInfo, extraData [32]byte) (*types.Transaction, error) { + return _Bridge.Contract.RevealTaprootDepositWithExtraData(&_Bridge.TransactOpts, fundingTx, reveal, extraData) +} + +// RevealTaprootDepositWithExtraData is a paid mutator transaction binding the contract method 0xa97c9f34. +// +// Solidity: function revealTaprootDepositWithExtraData((bytes4,bytes,bytes,bytes4) fundingTx, (uint32,bytes8,bytes20,bytes32,bytes20,bytes32,bytes4,address) reveal, bytes32 extraData) returns() +func (_Bridge *BridgeTransactorSession) RevealTaprootDepositWithExtraData(fundingTx BitcoinTxInfo, reveal DepositTaprootDepositRevealInfo, extraData [32]byte) (*types.Transaction, error) { + return _Bridge.Contract.RevealTaprootDepositWithExtraData(&_Bridge.TransactOpts, fundingTx, reveal, extraData) +} + +// SetEcdsaFraudRouter is a paid mutator transaction binding the contract method 0xba863979. +// +// Solidity: function setEcdsaFraudRouter(address ecdsaFraudRouter) returns() +func (_Bridge *BridgeTransactor) SetEcdsaFraudRouter(opts *bind.TransactOpts, ecdsaFraudRouter common.Address) (*types.Transaction, error) { + return _Bridge.contract.Transact(opts, "setEcdsaFraudRouter", ecdsaFraudRouter) +} + +// SetEcdsaFraudRouter is a paid mutator transaction binding the contract method 0xba863979. +// +// Solidity: function setEcdsaFraudRouter(address ecdsaFraudRouter) returns() +func (_Bridge *BridgeSession) SetEcdsaFraudRouter(ecdsaFraudRouter common.Address) (*types.Transaction, error) { + return _Bridge.Contract.SetEcdsaFraudRouter(&_Bridge.TransactOpts, ecdsaFraudRouter) +} + +// SetEcdsaFraudRouter is a paid mutator transaction binding the contract method 0xba863979. +// +// Solidity: function setEcdsaFraudRouter(address ecdsaFraudRouter) returns() +func (_Bridge *BridgeTransactorSession) SetEcdsaFraudRouter(ecdsaFraudRouter common.Address) (*types.Transaction, error) { + return _Bridge.Contract.SetEcdsaFraudRouter(&_Bridge.TransactOpts, ecdsaFraudRouter) +} + +// SetFrostWalletRegistry is a paid mutator transaction binding the contract method 0x07fe5dad. +// +// Solidity: function setFrostWalletRegistry(address frostWalletRegistry) returns() +func (_Bridge *BridgeTransactor) SetFrostWalletRegistry(opts *bind.TransactOpts, frostWalletRegistry common.Address) (*types.Transaction, error) { + return _Bridge.contract.Transact(opts, "setFrostWalletRegistry", frostWalletRegistry) +} + +// SetFrostWalletRegistry is a paid mutator transaction binding the contract method 0x07fe5dad. +// +// Solidity: function setFrostWalletRegistry(address frostWalletRegistry) returns() +func (_Bridge *BridgeSession) SetFrostWalletRegistry(frostWalletRegistry common.Address) (*types.Transaction, error) { + return _Bridge.Contract.SetFrostWalletRegistry(&_Bridge.TransactOpts, frostWalletRegistry) +} + +// SetFrostWalletRegistry is a paid mutator transaction binding the contract method 0x07fe5dad. +// +// Solidity: function setFrostWalletRegistry(address frostWalletRegistry) returns() +func (_Bridge *BridgeTransactorSession) SetFrostWalletRegistry(frostWalletRegistry common.Address) (*types.Transaction, error) { + return _Bridge.Contract.SetFrostWalletRegistry(&_Bridge.TransactOpts, frostWalletRegistry) +} + +// SetLifecycleRouter is a paid mutator transaction binding the contract method 0xdf5efac8. +// +// Solidity: function setLifecycleRouter(address lifecycleRouter) returns() +func (_Bridge *BridgeTransactor) SetLifecycleRouter(opts *bind.TransactOpts, lifecycleRouter common.Address) (*types.Transaction, error) { + return _Bridge.contract.Transact(opts, "setLifecycleRouter", lifecycleRouter) +} + +// SetLifecycleRouter is a paid mutator transaction binding the contract method 0xdf5efac8. +// +// Solidity: function setLifecycleRouter(address lifecycleRouter) returns() +func (_Bridge *BridgeSession) SetLifecycleRouter(lifecycleRouter common.Address) (*types.Transaction, error) { + return _Bridge.Contract.SetLifecycleRouter(&_Bridge.TransactOpts, lifecycleRouter) +} + +// SetLifecycleRouter is a paid mutator transaction binding the contract method 0xdf5efac8. +// +// Solidity: function setLifecycleRouter(address lifecycleRouter) returns() +func (_Bridge *BridgeTransactorSession) SetLifecycleRouter(lifecycleRouter common.Address) (*types.Transaction, error) { + return _Bridge.Contract.SetLifecycleRouter(&_Bridge.TransactOpts, lifecycleRouter) +} + +// SetP2TRFraudRouter is a paid mutator transaction binding the contract method 0x6247cf16. +// +// Solidity: function setP2TRFraudRouter(address p2trFraudRouter) returns() +func (_Bridge *BridgeTransactor) SetP2TRFraudRouter(opts *bind.TransactOpts, p2trFraudRouter common.Address) (*types.Transaction, error) { + return _Bridge.contract.Transact(opts, "setP2TRFraudRouter", p2trFraudRouter) +} + +// SetP2TRFraudRouter is a paid mutator transaction binding the contract method 0x6247cf16. +// +// Solidity: function setP2TRFraudRouter(address p2trFraudRouter) returns() +func (_Bridge *BridgeSession) SetP2TRFraudRouter(p2trFraudRouter common.Address) (*types.Transaction, error) { + return _Bridge.Contract.SetP2TRFraudRouter(&_Bridge.TransactOpts, p2trFraudRouter) +} + +// SetP2TRFraudRouter is a paid mutator transaction binding the contract method 0x6247cf16. +// +// Solidity: function setP2TRFraudRouter(address p2trFraudRouter) returns() +func (_Bridge *BridgeTransactorSession) SetP2TRFraudRouter(p2trFraudRouter common.Address) (*types.Transaction, error) { + return _Bridge.Contract.SetP2TRFraudRouter(&_Bridge.TransactOpts, p2trFraudRouter) +} + // SetRebateStaking is a paid mutator transaction binding the contract method 0xca73c462. // // Solidity: function setRebateStaking(address rebateStaking) returns() @@ -1758,6 +1967,48 @@ func (_Bridge *BridgeTransactorSession) SetVaultStatus(vault common.Address, isT return _Bridge.Contract.SetVaultStatus(&_Bridge.TransactOpts, vault, isTrusted) } +// SlashWalletForFraud is a paid mutator transaction binding the contract method 0x3f5dfabb. +// +// Solidity: function slashWalletForFraud(bytes20 walletPubKeyHash, uint32[] walletMembersIDs, address challenger) returns() +func (_Bridge *BridgeTransactor) SlashWalletForFraud(opts *bind.TransactOpts, walletPubKeyHash [20]byte, walletMembersIDs []uint32, challenger common.Address) (*types.Transaction, error) { + return _Bridge.contract.Transact(opts, "slashWalletForFraud", walletPubKeyHash, walletMembersIDs, challenger) +} + +// SlashWalletForFraud is a paid mutator transaction binding the contract method 0x3f5dfabb. +// +// Solidity: function slashWalletForFraud(bytes20 walletPubKeyHash, uint32[] walletMembersIDs, address challenger) returns() +func (_Bridge *BridgeSession) SlashWalletForFraud(walletPubKeyHash [20]byte, walletMembersIDs []uint32, challenger common.Address) (*types.Transaction, error) { + return _Bridge.Contract.SlashWalletForFraud(&_Bridge.TransactOpts, walletPubKeyHash, walletMembersIDs, challenger) +} + +// SlashWalletForFraud is a paid mutator transaction binding the contract method 0x3f5dfabb. +// +// Solidity: function slashWalletForFraud(bytes20 walletPubKeyHash, uint32[] walletMembersIDs, address challenger) returns() +func (_Bridge *BridgeTransactorSession) SlashWalletForFraud(walletPubKeyHash [20]byte, walletMembersIDs []uint32, challenger common.Address) (*types.Transaction, error) { + return _Bridge.Contract.SlashWalletForFraud(&_Bridge.TransactOpts, walletPubKeyHash, walletMembersIDs, challenger) +} + +// SlashWalletForP2TRFraud is a paid mutator transaction binding the contract method 0xc823b5cf. +// +// Solidity: function slashWalletForP2TRFraud(bytes20 walletPubKeyHash, uint32[] walletMembersIDs, address challenger) returns() +func (_Bridge *BridgeTransactor) SlashWalletForP2TRFraud(opts *bind.TransactOpts, walletPubKeyHash [20]byte, walletMembersIDs []uint32, challenger common.Address) (*types.Transaction, error) { + return _Bridge.contract.Transact(opts, "slashWalletForP2TRFraud", walletPubKeyHash, walletMembersIDs, challenger) +} + +// SlashWalletForP2TRFraud is a paid mutator transaction binding the contract method 0xc823b5cf. +// +// Solidity: function slashWalletForP2TRFraud(bytes20 walletPubKeyHash, uint32[] walletMembersIDs, address challenger) returns() +func (_Bridge *BridgeSession) SlashWalletForP2TRFraud(walletPubKeyHash [20]byte, walletMembersIDs []uint32, challenger common.Address) (*types.Transaction, error) { + return _Bridge.Contract.SlashWalletForP2TRFraud(&_Bridge.TransactOpts, walletPubKeyHash, walletMembersIDs, challenger) +} + +// SlashWalletForP2TRFraud is a paid mutator transaction binding the contract method 0xc823b5cf. +// +// Solidity: function slashWalletForP2TRFraud(bytes20 walletPubKeyHash, uint32[] walletMembersIDs, address challenger) returns() +func (_Bridge *BridgeTransactorSession) SlashWalletForP2TRFraud(walletPubKeyHash [20]byte, walletMembersIDs []uint32, challenger common.Address) (*types.Transaction, error) { + return _Bridge.Contract.SlashWalletForP2TRFraud(&_Bridge.TransactOpts, walletPubKeyHash, walletMembersIDs, challenger) +} + // SubmitDepositSweepProof is a paid mutator transaction binding the contract method 0xbd150131. // // Solidity: function submitDepositSweepProof((bytes4,bytes,bytes,bytes4) sweepTx, (bytes,uint256,bytes,bytes32,bytes) sweepProof, (bytes32,uint32,uint64) mainUtxo, address vault) returns() @@ -1779,27 +2030,6 @@ func (_Bridge *BridgeTransactorSession) SubmitDepositSweepProof(sweepTx BitcoinT return _Bridge.Contract.SubmitDepositSweepProof(&_Bridge.TransactOpts, sweepTx, sweepProof, mainUtxo, vault) } -// SubmitFraudChallenge is a paid mutator transaction binding the contract method 0x685ce1b1. -// -// Solidity: function submitFraudChallenge(bytes walletPublicKey, bytes preimageSha256, (bytes32,bytes32,uint8) signature) payable returns() -func (_Bridge *BridgeTransactor) SubmitFraudChallenge(opts *bind.TransactOpts, walletPublicKey []byte, preimageSha256 []byte, signature BitcoinTxRSVSignature) (*types.Transaction, error) { - return _Bridge.contract.Transact(opts, "submitFraudChallenge", walletPublicKey, preimageSha256, signature) -} - -// SubmitFraudChallenge is a paid mutator transaction binding the contract method 0x685ce1b1. -// -// Solidity: function submitFraudChallenge(bytes walletPublicKey, bytes preimageSha256, (bytes32,bytes32,uint8) signature) payable returns() -func (_Bridge *BridgeSession) SubmitFraudChallenge(walletPublicKey []byte, preimageSha256 []byte, signature BitcoinTxRSVSignature) (*types.Transaction, error) { - return _Bridge.Contract.SubmitFraudChallenge(&_Bridge.TransactOpts, walletPublicKey, preimageSha256, signature) -} - -// SubmitFraudChallenge is a paid mutator transaction binding the contract method 0x685ce1b1. -// -// Solidity: function submitFraudChallenge(bytes walletPublicKey, bytes preimageSha256, (bytes32,bytes32,uint8) signature) payable returns() -func (_Bridge *BridgeTransactorSession) SubmitFraudChallenge(walletPublicKey []byte, preimageSha256 []byte, signature BitcoinTxRSVSignature) (*types.Transaction, error) { - return _Bridge.Contract.SubmitFraudChallenge(&_Bridge.TransactOpts, walletPublicKey, preimageSha256, signature) -} - // SubmitMovedFundsSweepProof is a paid mutator transaction binding the contract method 0x9821c38b. // // Solidity: function submitMovedFundsSweepProof((bytes4,bytes,bytes,bytes4) sweepTx, (bytes,uint256,bytes,bytes32,bytes) sweepProof, (bytes32,uint32,uint64) mainUtxo) returns() @@ -2610,9 +2840,9 @@ func (_Bridge *BridgeFilterer) ParseDepositsSwept(log types.Log) (*BridgeDeposit return event, nil } -// BridgeFraudChallengeDefeatTimedOutIterator is returned from FilterFraudChallengeDefeatTimedOut and is used to iterate over the raw logs and unpacked data for FraudChallengeDefeatTimedOut events raised by the Bridge contract. -type BridgeFraudChallengeDefeatTimedOutIterator struct { - Event *BridgeFraudChallengeDefeatTimedOut // Event containing the contract specifics and raw log +// BridgeEcdsaFraudRouterSetIterator is returned from FilterEcdsaFraudRouterSet and is used to iterate over the raw logs and unpacked data for EcdsaFraudRouterSet events raised by the Bridge contract. +type BridgeEcdsaFraudRouterSetIterator struct { + Event *BridgeEcdsaFraudRouterSet // Event containing the contract specifics and raw log contract *bind.BoundContract // Generic contract to use for unpacking event data event string // Event name to use for unpacking event data @@ -2626,7 +2856,7 @@ type BridgeFraudChallengeDefeatTimedOutIterator struct { // Next advances the iterator to the subsequent event, returning whether there // are any more events found. In case of a retrieval or parsing error, false is // returned and Error() can be queried for the exact failure. -func (it *BridgeFraudChallengeDefeatTimedOutIterator) Next() bool { +func (it *BridgeEcdsaFraudRouterSetIterator) Next() bool { // If the iterator failed, stop iterating if it.fail != nil { return false @@ -2635,7 +2865,7 @@ func (it *BridgeFraudChallengeDefeatTimedOutIterator) Next() bool { if it.done { select { case log := <-it.logs: - it.Event = new(BridgeFraudChallengeDefeatTimedOut) + it.Event = new(BridgeEcdsaFraudRouterSet) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -2650,7 +2880,7 @@ func (it *BridgeFraudChallengeDefeatTimedOutIterator) Next() bool { // Iterator still in progress, wait for either a data or an error event select { case log := <-it.logs: - it.Event = new(BridgeFraudChallengeDefeatTimedOut) + it.Event = new(BridgeEcdsaFraudRouterSet) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -2666,52 +2896,41 @@ func (it *BridgeFraudChallengeDefeatTimedOutIterator) Next() bool { } // Error returns any retrieval or parsing error occurred during filtering. -func (it *BridgeFraudChallengeDefeatTimedOutIterator) Error() error { +func (it *BridgeEcdsaFraudRouterSetIterator) Error() error { return it.fail } // Close terminates the iteration process, releasing any pending underlying // resources. -func (it *BridgeFraudChallengeDefeatTimedOutIterator) Close() error { +func (it *BridgeEcdsaFraudRouterSetIterator) Close() error { it.sub.Unsubscribe() return nil } -// BridgeFraudChallengeDefeatTimedOut represents a FraudChallengeDefeatTimedOut event raised by the Bridge contract. -type BridgeFraudChallengeDefeatTimedOut struct { - WalletPubKeyHash [20]byte - Sighash [32]byte +// BridgeEcdsaFraudRouterSet represents a EcdsaFraudRouterSet event raised by the Bridge contract. +type BridgeEcdsaFraudRouterSet struct { + EcdsaFraudRouter common.Address Raw types.Log // Blockchain specific contextual infos } -// FilterFraudChallengeDefeatTimedOut is a free log retrieval operation binding the contract event 0x635230b60143449f10a365568e2bd95e3e8aaed03855631722941c2bad634b77. +// FilterEcdsaFraudRouterSet is a free log retrieval operation binding the contract event 0x74b82ffdaa86ef071c7c5083b76052a32b9d67ead5e1013cba6979a28d1851c1. // -// Solidity: event FraudChallengeDefeatTimedOut(bytes20 indexed walletPubKeyHash, bytes32 sighash) -func (_Bridge *BridgeFilterer) FilterFraudChallengeDefeatTimedOut(opts *bind.FilterOpts, walletPubKeyHash [][20]byte) (*BridgeFraudChallengeDefeatTimedOutIterator, error) { - - var walletPubKeyHashRule []interface{} - for _, walletPubKeyHashItem := range walletPubKeyHash { - walletPubKeyHashRule = append(walletPubKeyHashRule, walletPubKeyHashItem) - } +// Solidity: event EcdsaFraudRouterSet(address ecdsaFraudRouter) +func (_Bridge *BridgeFilterer) FilterEcdsaFraudRouterSet(opts *bind.FilterOpts) (*BridgeEcdsaFraudRouterSetIterator, error) { - logs, sub, err := _Bridge.contract.FilterLogs(opts, "FraudChallengeDefeatTimedOut", walletPubKeyHashRule) + logs, sub, err := _Bridge.contract.FilterLogs(opts, "EcdsaFraudRouterSet") if err != nil { return nil, err } - return &BridgeFraudChallengeDefeatTimedOutIterator{contract: _Bridge.contract, event: "FraudChallengeDefeatTimedOut", logs: logs, sub: sub}, nil + return &BridgeEcdsaFraudRouterSetIterator{contract: _Bridge.contract, event: "EcdsaFraudRouterSet", logs: logs, sub: sub}, nil } -// WatchFraudChallengeDefeatTimedOut is a free log subscription operation binding the contract event 0x635230b60143449f10a365568e2bd95e3e8aaed03855631722941c2bad634b77. +// WatchEcdsaFraudRouterSet is a free log subscription operation binding the contract event 0x74b82ffdaa86ef071c7c5083b76052a32b9d67ead5e1013cba6979a28d1851c1. // -// Solidity: event FraudChallengeDefeatTimedOut(bytes20 indexed walletPubKeyHash, bytes32 sighash) -func (_Bridge *BridgeFilterer) WatchFraudChallengeDefeatTimedOut(opts *bind.WatchOpts, sink chan<- *BridgeFraudChallengeDefeatTimedOut, walletPubKeyHash [][20]byte) (event.Subscription, error) { - - var walletPubKeyHashRule []interface{} - for _, walletPubKeyHashItem := range walletPubKeyHash { - walletPubKeyHashRule = append(walletPubKeyHashRule, walletPubKeyHashItem) - } +// Solidity: event EcdsaFraudRouterSet(address ecdsaFraudRouter) +func (_Bridge *BridgeFilterer) WatchEcdsaFraudRouterSet(opts *bind.WatchOpts, sink chan<- *BridgeEcdsaFraudRouterSet) (event.Subscription, error) { - logs, sub, err := _Bridge.contract.WatchLogs(opts, "FraudChallengeDefeatTimedOut", walletPubKeyHashRule) + logs, sub, err := _Bridge.contract.WatchLogs(opts, "EcdsaFraudRouterSet") if err != nil { return nil, err } @@ -2721,8 +2940,8 @@ func (_Bridge *BridgeFilterer) WatchFraudChallengeDefeatTimedOut(opts *bind.Watc select { case log := <-logs: // New log arrived, parse the event and forward to the user - event := new(BridgeFraudChallengeDefeatTimedOut) - if err := _Bridge.contract.UnpackLog(event, "FraudChallengeDefeatTimedOut", log); err != nil { + event := new(BridgeEcdsaFraudRouterSet) + if err := _Bridge.contract.UnpackLog(event, "EcdsaFraudRouterSet", log); err != nil { return err } event.Raw = log @@ -2743,21 +2962,21 @@ func (_Bridge *BridgeFilterer) WatchFraudChallengeDefeatTimedOut(opts *bind.Watc }), nil } -// ParseFraudChallengeDefeatTimedOut is a log parse operation binding the contract event 0x635230b60143449f10a365568e2bd95e3e8aaed03855631722941c2bad634b77. +// ParseEcdsaFraudRouterSet is a log parse operation binding the contract event 0x74b82ffdaa86ef071c7c5083b76052a32b9d67ead5e1013cba6979a28d1851c1. // -// Solidity: event FraudChallengeDefeatTimedOut(bytes20 indexed walletPubKeyHash, bytes32 sighash) -func (_Bridge *BridgeFilterer) ParseFraudChallengeDefeatTimedOut(log types.Log) (*BridgeFraudChallengeDefeatTimedOut, error) { - event := new(BridgeFraudChallengeDefeatTimedOut) - if err := _Bridge.contract.UnpackLog(event, "FraudChallengeDefeatTimedOut", log); err != nil { +// Solidity: event EcdsaFraudRouterSet(address ecdsaFraudRouter) +func (_Bridge *BridgeFilterer) ParseEcdsaFraudRouterSet(log types.Log) (*BridgeEcdsaFraudRouterSet, error) { + event := new(BridgeEcdsaFraudRouterSet) + if err := _Bridge.contract.UnpackLog(event, "EcdsaFraudRouterSet", log); err != nil { return nil, err } event.Raw = log return event, nil } -// BridgeFraudChallengeDefeatedIterator is returned from FilterFraudChallengeDefeated and is used to iterate over the raw logs and unpacked data for FraudChallengeDefeated events raised by the Bridge contract. -type BridgeFraudChallengeDefeatedIterator struct { - Event *BridgeFraudChallengeDefeated // Event containing the contract specifics and raw log +// BridgeEcdsaRetiredIterator is returned from FilterEcdsaRetired and is used to iterate over the raw logs and unpacked data for EcdsaRetired events raised by the Bridge contract. +type BridgeEcdsaRetiredIterator struct { + Event *BridgeEcdsaRetired // Event containing the contract specifics and raw log contract *bind.BoundContract // Generic contract to use for unpacking event data event string // Event name to use for unpacking event data @@ -2771,7 +2990,7 @@ type BridgeFraudChallengeDefeatedIterator struct { // Next advances the iterator to the subsequent event, returning whether there // are any more events found. In case of a retrieval or parsing error, false is // returned and Error() can be queried for the exact failure. -func (it *BridgeFraudChallengeDefeatedIterator) Next() bool { +func (it *BridgeEcdsaRetiredIterator) Next() bool { // If the iterator failed, stop iterating if it.fail != nil { return false @@ -2780,7 +2999,7 @@ func (it *BridgeFraudChallengeDefeatedIterator) Next() bool { if it.done { select { case log := <-it.logs: - it.Event = new(BridgeFraudChallengeDefeated) + it.Event = new(BridgeEcdsaRetired) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -2795,7 +3014,7 @@ func (it *BridgeFraudChallengeDefeatedIterator) Next() bool { // Iterator still in progress, wait for either a data or an error event select { case log := <-it.logs: - it.Event = new(BridgeFraudChallengeDefeated) + it.Event = new(BridgeEcdsaRetired) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -2811,52 +3030,40 @@ func (it *BridgeFraudChallengeDefeatedIterator) Next() bool { } // Error returns any retrieval or parsing error occurred during filtering. -func (it *BridgeFraudChallengeDefeatedIterator) Error() error { +func (it *BridgeEcdsaRetiredIterator) Error() error { return it.fail } // Close terminates the iteration process, releasing any pending underlying // resources. -func (it *BridgeFraudChallengeDefeatedIterator) Close() error { +func (it *BridgeEcdsaRetiredIterator) Close() error { it.sub.Unsubscribe() return nil } -// BridgeFraudChallengeDefeated represents a FraudChallengeDefeated event raised by the Bridge contract. -type BridgeFraudChallengeDefeated struct { - WalletPubKeyHash [20]byte - Sighash [32]byte - Raw types.Log // Blockchain specific contextual infos +// BridgeEcdsaRetired represents a EcdsaRetired event raised by the Bridge contract. +type BridgeEcdsaRetired struct { + Raw types.Log // Blockchain specific contextual infos } -// FilterFraudChallengeDefeated is a free log retrieval operation binding the contract event 0x6ff720470ffad78f316655e2c7fc77a76763c13de0e19ee52149916ba7e44d3b. +// FilterEcdsaRetired is a free log retrieval operation binding the contract event 0xcfd6ec30c5fce5bd571f7b6c440f26edaa4ed4e92387c12806fc47ed888fd014. // -// Solidity: event FraudChallengeDefeated(bytes20 indexed walletPubKeyHash, bytes32 sighash) -func (_Bridge *BridgeFilterer) FilterFraudChallengeDefeated(opts *bind.FilterOpts, walletPubKeyHash [][20]byte) (*BridgeFraudChallengeDefeatedIterator, error) { - - var walletPubKeyHashRule []interface{} - for _, walletPubKeyHashItem := range walletPubKeyHash { - walletPubKeyHashRule = append(walletPubKeyHashRule, walletPubKeyHashItem) - } +// Solidity: event EcdsaRetired() +func (_Bridge *BridgeFilterer) FilterEcdsaRetired(opts *bind.FilterOpts) (*BridgeEcdsaRetiredIterator, error) { - logs, sub, err := _Bridge.contract.FilterLogs(opts, "FraudChallengeDefeated", walletPubKeyHashRule) + logs, sub, err := _Bridge.contract.FilterLogs(opts, "EcdsaRetired") if err != nil { return nil, err } - return &BridgeFraudChallengeDefeatedIterator{contract: _Bridge.contract, event: "FraudChallengeDefeated", logs: logs, sub: sub}, nil + return &BridgeEcdsaRetiredIterator{contract: _Bridge.contract, event: "EcdsaRetired", logs: logs, sub: sub}, nil } -// WatchFraudChallengeDefeated is a free log subscription operation binding the contract event 0x6ff720470ffad78f316655e2c7fc77a76763c13de0e19ee52149916ba7e44d3b. +// WatchEcdsaRetired is a free log subscription operation binding the contract event 0xcfd6ec30c5fce5bd571f7b6c440f26edaa4ed4e92387c12806fc47ed888fd014. // -// Solidity: event FraudChallengeDefeated(bytes20 indexed walletPubKeyHash, bytes32 sighash) -func (_Bridge *BridgeFilterer) WatchFraudChallengeDefeated(opts *bind.WatchOpts, sink chan<- *BridgeFraudChallengeDefeated, walletPubKeyHash [][20]byte) (event.Subscription, error) { - - var walletPubKeyHashRule []interface{} - for _, walletPubKeyHashItem := range walletPubKeyHash { - walletPubKeyHashRule = append(walletPubKeyHashRule, walletPubKeyHashItem) - } +// Solidity: event EcdsaRetired() +func (_Bridge *BridgeFilterer) WatchEcdsaRetired(opts *bind.WatchOpts, sink chan<- *BridgeEcdsaRetired) (event.Subscription, error) { - logs, sub, err := _Bridge.contract.WatchLogs(opts, "FraudChallengeDefeated", walletPubKeyHashRule) + logs, sub, err := _Bridge.contract.WatchLogs(opts, "EcdsaRetired") if err != nil { return nil, err } @@ -2866,8 +3073,8 @@ func (_Bridge *BridgeFilterer) WatchFraudChallengeDefeated(opts *bind.WatchOpts, select { case log := <-logs: // New log arrived, parse the event and forward to the user - event := new(BridgeFraudChallengeDefeated) - if err := _Bridge.contract.UnpackLog(event, "FraudChallengeDefeated", log); err != nil { + event := new(BridgeEcdsaRetired) + if err := _Bridge.contract.UnpackLog(event, "EcdsaRetired", log); err != nil { return err } event.Raw = log @@ -2888,21 +3095,21 @@ func (_Bridge *BridgeFilterer) WatchFraudChallengeDefeated(opts *bind.WatchOpts, }), nil } -// ParseFraudChallengeDefeated is a log parse operation binding the contract event 0x6ff720470ffad78f316655e2c7fc77a76763c13de0e19ee52149916ba7e44d3b. +// ParseEcdsaRetired is a log parse operation binding the contract event 0xcfd6ec30c5fce5bd571f7b6c440f26edaa4ed4e92387c12806fc47ed888fd014. // -// Solidity: event FraudChallengeDefeated(bytes20 indexed walletPubKeyHash, bytes32 sighash) -func (_Bridge *BridgeFilterer) ParseFraudChallengeDefeated(log types.Log) (*BridgeFraudChallengeDefeated, error) { - event := new(BridgeFraudChallengeDefeated) - if err := _Bridge.contract.UnpackLog(event, "FraudChallengeDefeated", log); err != nil { +// Solidity: event EcdsaRetired() +func (_Bridge *BridgeFilterer) ParseEcdsaRetired(log types.Log) (*BridgeEcdsaRetired, error) { + event := new(BridgeEcdsaRetired) + if err := _Bridge.contract.UnpackLog(event, "EcdsaRetired", log); err != nil { return nil, err } event.Raw = log return event, nil } -// BridgeFraudChallengeSubmittedIterator is returned from FilterFraudChallengeSubmitted and is used to iterate over the raw logs and unpacked data for FraudChallengeSubmitted events raised by the Bridge contract. -type BridgeFraudChallengeSubmittedIterator struct { - Event *BridgeFraudChallengeSubmitted // Event containing the contract specifics and raw log +// BridgeFraudParametersUpdatedIterator is returned from FilterFraudParametersUpdated and is used to iterate over the raw logs and unpacked data for FraudParametersUpdated events raised by the Bridge contract. +type BridgeFraudParametersUpdatedIterator struct { + Event *BridgeFraudParametersUpdated // Event containing the contract specifics and raw log contract *bind.BoundContract // Generic contract to use for unpacking event data event string // Event name to use for unpacking event data @@ -2916,7 +3123,7 @@ type BridgeFraudChallengeSubmittedIterator struct { // Next advances the iterator to the subsequent event, returning whether there // are any more events found. In case of a retrieval or parsing error, false is // returned and Error() can be queried for the exact failure. -func (it *BridgeFraudChallengeSubmittedIterator) Next() bool { +func (it *BridgeFraudParametersUpdatedIterator) Next() bool { // If the iterator failed, stop iterating if it.fail != nil { return false @@ -2925,7 +3132,7 @@ func (it *BridgeFraudChallengeSubmittedIterator) Next() bool { if it.done { select { case log := <-it.logs: - it.Event = new(BridgeFraudChallengeSubmitted) + it.Event = new(BridgeFraudParametersUpdated) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -2940,7 +3147,7 @@ func (it *BridgeFraudChallengeSubmittedIterator) Next() bool { // Iterator still in progress, wait for either a data or an error event select { case log := <-it.logs: - it.Event = new(BridgeFraudChallengeSubmitted) + it.Event = new(BridgeFraudParametersUpdated) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -2956,55 +3163,44 @@ func (it *BridgeFraudChallengeSubmittedIterator) Next() bool { } // Error returns any retrieval or parsing error occurred during filtering. -func (it *BridgeFraudChallengeSubmittedIterator) Error() error { +func (it *BridgeFraudParametersUpdatedIterator) Error() error { return it.fail } // Close terminates the iteration process, releasing any pending underlying // resources. -func (it *BridgeFraudChallengeSubmittedIterator) Close() error { +func (it *BridgeFraudParametersUpdatedIterator) Close() error { it.sub.Unsubscribe() return nil } -// BridgeFraudChallengeSubmitted represents a FraudChallengeSubmitted event raised by the Bridge contract. -type BridgeFraudChallengeSubmitted struct { - WalletPubKeyHash [20]byte - Sighash [32]byte - V uint8 - R [32]byte - S [32]byte - Raw types.Log // Blockchain specific contextual infos +// BridgeFraudParametersUpdated represents a FraudParametersUpdated event raised by the Bridge contract. +type BridgeFraudParametersUpdated struct { + FraudChallengeDepositAmount *big.Int + FraudChallengeDefeatTimeout uint32 + FraudSlashingAmount *big.Int + FraudNotifierRewardMultiplier uint32 + Raw types.Log // Blockchain specific contextual infos } -// FilterFraudChallengeSubmitted is a free log retrieval operation binding the contract event 0xf4aa58d09ba5de017eac597806dfcfc2cad287816cb1eb7729a032c82680c94d. +// FilterFraudParametersUpdated is a free log retrieval operation binding the contract event 0xc6d044ae75b875a43eb23bedc79d2b694b00ed95b5b8bf2a657328af9dda090d. // -// Solidity: event FraudChallengeSubmitted(bytes20 indexed walletPubKeyHash, bytes32 sighash, uint8 v, bytes32 r, bytes32 s) -func (_Bridge *BridgeFilterer) FilterFraudChallengeSubmitted(opts *bind.FilterOpts, walletPubKeyHash [][20]byte) (*BridgeFraudChallengeSubmittedIterator, error) { - - var walletPubKeyHashRule []interface{} - for _, walletPubKeyHashItem := range walletPubKeyHash { - walletPubKeyHashRule = append(walletPubKeyHashRule, walletPubKeyHashItem) - } +// Solidity: event FraudParametersUpdated(uint96 fraudChallengeDepositAmount, uint32 fraudChallengeDefeatTimeout, uint96 fraudSlashingAmount, uint32 fraudNotifierRewardMultiplier) +func (_Bridge *BridgeFilterer) FilterFraudParametersUpdated(opts *bind.FilterOpts) (*BridgeFraudParametersUpdatedIterator, error) { - logs, sub, err := _Bridge.contract.FilterLogs(opts, "FraudChallengeSubmitted", walletPubKeyHashRule) + logs, sub, err := _Bridge.contract.FilterLogs(opts, "FraudParametersUpdated") if err != nil { return nil, err } - return &BridgeFraudChallengeSubmittedIterator{contract: _Bridge.contract, event: "FraudChallengeSubmitted", logs: logs, sub: sub}, nil + return &BridgeFraudParametersUpdatedIterator{contract: _Bridge.contract, event: "FraudParametersUpdated", logs: logs, sub: sub}, nil } -// WatchFraudChallengeSubmitted is a free log subscription operation binding the contract event 0xf4aa58d09ba5de017eac597806dfcfc2cad287816cb1eb7729a032c82680c94d. +// WatchFraudParametersUpdated is a free log subscription operation binding the contract event 0xc6d044ae75b875a43eb23bedc79d2b694b00ed95b5b8bf2a657328af9dda090d. // -// Solidity: event FraudChallengeSubmitted(bytes20 indexed walletPubKeyHash, bytes32 sighash, uint8 v, bytes32 r, bytes32 s) -func (_Bridge *BridgeFilterer) WatchFraudChallengeSubmitted(opts *bind.WatchOpts, sink chan<- *BridgeFraudChallengeSubmitted, walletPubKeyHash [][20]byte) (event.Subscription, error) { - - var walletPubKeyHashRule []interface{} - for _, walletPubKeyHashItem := range walletPubKeyHash { - walletPubKeyHashRule = append(walletPubKeyHashRule, walletPubKeyHashItem) - } +// Solidity: event FraudParametersUpdated(uint96 fraudChallengeDepositAmount, uint32 fraudChallengeDefeatTimeout, uint96 fraudSlashingAmount, uint32 fraudNotifierRewardMultiplier) +func (_Bridge *BridgeFilterer) WatchFraudParametersUpdated(opts *bind.WatchOpts, sink chan<- *BridgeFraudParametersUpdated) (event.Subscription, error) { - logs, sub, err := _Bridge.contract.WatchLogs(opts, "FraudChallengeSubmitted", walletPubKeyHashRule) + logs, sub, err := _Bridge.contract.WatchLogs(opts, "FraudParametersUpdated") if err != nil { return nil, err } @@ -3014,8 +3210,8 @@ func (_Bridge *BridgeFilterer) WatchFraudChallengeSubmitted(opts *bind.WatchOpts select { case log := <-logs: // New log arrived, parse the event and forward to the user - event := new(BridgeFraudChallengeSubmitted) - if err := _Bridge.contract.UnpackLog(event, "FraudChallengeSubmitted", log); err != nil { + event := new(BridgeFraudParametersUpdated) + if err := _Bridge.contract.UnpackLog(event, "FraudParametersUpdated", log); err != nil { return err } event.Raw = log @@ -3036,21 +3232,21 @@ func (_Bridge *BridgeFilterer) WatchFraudChallengeSubmitted(opts *bind.WatchOpts }), nil } -// ParseFraudChallengeSubmitted is a log parse operation binding the contract event 0xf4aa58d09ba5de017eac597806dfcfc2cad287816cb1eb7729a032c82680c94d. +// ParseFraudParametersUpdated is a log parse operation binding the contract event 0xc6d044ae75b875a43eb23bedc79d2b694b00ed95b5b8bf2a657328af9dda090d. // -// Solidity: event FraudChallengeSubmitted(bytes20 indexed walletPubKeyHash, bytes32 sighash, uint8 v, bytes32 r, bytes32 s) -func (_Bridge *BridgeFilterer) ParseFraudChallengeSubmitted(log types.Log) (*BridgeFraudChallengeSubmitted, error) { - event := new(BridgeFraudChallengeSubmitted) - if err := _Bridge.contract.UnpackLog(event, "FraudChallengeSubmitted", log); err != nil { +// Solidity: event FraudParametersUpdated(uint96 fraudChallengeDepositAmount, uint32 fraudChallengeDefeatTimeout, uint96 fraudSlashingAmount, uint32 fraudNotifierRewardMultiplier) +func (_Bridge *BridgeFilterer) ParseFraudParametersUpdated(log types.Log) (*BridgeFraudParametersUpdated, error) { + event := new(BridgeFraudParametersUpdated) + if err := _Bridge.contract.UnpackLog(event, "FraudParametersUpdated", log); err != nil { return nil, err } event.Raw = log return event, nil } -// BridgeFraudParametersUpdatedIterator is returned from FilterFraudParametersUpdated and is used to iterate over the raw logs and unpacked data for FraudParametersUpdated events raised by the Bridge contract. -type BridgeFraudParametersUpdatedIterator struct { - Event *BridgeFraudParametersUpdated // Event containing the contract specifics and raw log +// BridgeFrostWalletRegistrySetIterator is returned from FilterFrostWalletRegistrySet and is used to iterate over the raw logs and unpacked data for FrostWalletRegistrySet events raised by the Bridge contract. +type BridgeFrostWalletRegistrySetIterator struct { + Event *BridgeFrostWalletRegistrySet // Event containing the contract specifics and raw log contract *bind.BoundContract // Generic contract to use for unpacking event data event string // Event name to use for unpacking event data @@ -3064,7 +3260,7 @@ type BridgeFraudParametersUpdatedIterator struct { // Next advances the iterator to the subsequent event, returning whether there // are any more events found. In case of a retrieval or parsing error, false is // returned and Error() can be queried for the exact failure. -func (it *BridgeFraudParametersUpdatedIterator) Next() bool { +func (it *BridgeFrostWalletRegistrySetIterator) Next() bool { // If the iterator failed, stop iterating if it.fail != nil { return false @@ -3073,7 +3269,7 @@ func (it *BridgeFraudParametersUpdatedIterator) Next() bool { if it.done { select { case log := <-it.logs: - it.Event = new(BridgeFraudParametersUpdated) + it.Event = new(BridgeFrostWalletRegistrySet) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -3088,7 +3284,7 @@ func (it *BridgeFraudParametersUpdatedIterator) Next() bool { // Iterator still in progress, wait for either a data or an error event select { case log := <-it.logs: - it.Event = new(BridgeFraudParametersUpdated) + it.Event = new(BridgeFrostWalletRegistrySet) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -3104,44 +3300,41 @@ func (it *BridgeFraudParametersUpdatedIterator) Next() bool { } // Error returns any retrieval or parsing error occurred during filtering. -func (it *BridgeFraudParametersUpdatedIterator) Error() error { +func (it *BridgeFrostWalletRegistrySetIterator) Error() error { return it.fail } // Close terminates the iteration process, releasing any pending underlying // resources. -func (it *BridgeFraudParametersUpdatedIterator) Close() error { +func (it *BridgeFrostWalletRegistrySetIterator) Close() error { it.sub.Unsubscribe() return nil } -// BridgeFraudParametersUpdated represents a FraudParametersUpdated event raised by the Bridge contract. -type BridgeFraudParametersUpdated struct { - FraudChallengeDepositAmount *big.Int - FraudChallengeDefeatTimeout uint32 - FraudSlashingAmount *big.Int - FraudNotifierRewardMultiplier uint32 - Raw types.Log // Blockchain specific contextual infos +// BridgeFrostWalletRegistrySet represents a FrostWalletRegistrySet event raised by the Bridge contract. +type BridgeFrostWalletRegistrySet struct { + FrostWalletRegistry common.Address + Raw types.Log // Blockchain specific contextual infos } -// FilterFraudParametersUpdated is a free log retrieval operation binding the contract event 0xc6d044ae75b875a43eb23bedc79d2b694b00ed95b5b8bf2a657328af9dda090d. +// FilterFrostWalletRegistrySet is a free log retrieval operation binding the contract event 0xdbe373e942a6a777b9b8e4970445ff3dee716310d6d5d2265c7b01947776b6df. // -// Solidity: event FraudParametersUpdated(uint96 fraudChallengeDepositAmount, uint32 fraudChallengeDefeatTimeout, uint96 fraudSlashingAmount, uint32 fraudNotifierRewardMultiplier) -func (_Bridge *BridgeFilterer) FilterFraudParametersUpdated(opts *bind.FilterOpts) (*BridgeFraudParametersUpdatedIterator, error) { +// Solidity: event FrostWalletRegistrySet(address frostWalletRegistry) +func (_Bridge *BridgeFilterer) FilterFrostWalletRegistrySet(opts *bind.FilterOpts) (*BridgeFrostWalletRegistrySetIterator, error) { - logs, sub, err := _Bridge.contract.FilterLogs(opts, "FraudParametersUpdated") + logs, sub, err := _Bridge.contract.FilterLogs(opts, "FrostWalletRegistrySet") if err != nil { return nil, err } - return &BridgeFraudParametersUpdatedIterator{contract: _Bridge.contract, event: "FraudParametersUpdated", logs: logs, sub: sub}, nil + return &BridgeFrostWalletRegistrySetIterator{contract: _Bridge.contract, event: "FrostWalletRegistrySet", logs: logs, sub: sub}, nil } -// WatchFraudParametersUpdated is a free log subscription operation binding the contract event 0xc6d044ae75b875a43eb23bedc79d2b694b00ed95b5b8bf2a657328af9dda090d. +// WatchFrostWalletRegistrySet is a free log subscription operation binding the contract event 0xdbe373e942a6a777b9b8e4970445ff3dee716310d6d5d2265c7b01947776b6df. // -// Solidity: event FraudParametersUpdated(uint96 fraudChallengeDepositAmount, uint32 fraudChallengeDefeatTimeout, uint96 fraudSlashingAmount, uint32 fraudNotifierRewardMultiplier) -func (_Bridge *BridgeFilterer) WatchFraudParametersUpdated(opts *bind.WatchOpts, sink chan<- *BridgeFraudParametersUpdated) (event.Subscription, error) { +// Solidity: event FrostWalletRegistrySet(address frostWalletRegistry) +func (_Bridge *BridgeFilterer) WatchFrostWalletRegistrySet(opts *bind.WatchOpts, sink chan<- *BridgeFrostWalletRegistrySet) (event.Subscription, error) { - logs, sub, err := _Bridge.contract.WatchLogs(opts, "FraudParametersUpdated") + logs, sub, err := _Bridge.contract.WatchLogs(opts, "FrostWalletRegistrySet") if err != nil { return nil, err } @@ -3151,8 +3344,8 @@ func (_Bridge *BridgeFilterer) WatchFraudParametersUpdated(opts *bind.WatchOpts, select { case log := <-logs: // New log arrived, parse the event and forward to the user - event := new(BridgeFraudParametersUpdated) - if err := _Bridge.contract.UnpackLog(event, "FraudParametersUpdated", log); err != nil { + event := new(BridgeFrostWalletRegistrySet) + if err := _Bridge.contract.UnpackLog(event, "FrostWalletRegistrySet", log); err != nil { return err } event.Raw = log @@ -3173,12 +3366,12 @@ func (_Bridge *BridgeFilterer) WatchFraudParametersUpdated(opts *bind.WatchOpts, }), nil } -// ParseFraudParametersUpdated is a log parse operation binding the contract event 0xc6d044ae75b875a43eb23bedc79d2b694b00ed95b5b8bf2a657328af9dda090d. +// ParseFrostWalletRegistrySet is a log parse operation binding the contract event 0xdbe373e942a6a777b9b8e4970445ff3dee716310d6d5d2265c7b01947776b6df. // -// Solidity: event FraudParametersUpdated(uint96 fraudChallengeDepositAmount, uint32 fraudChallengeDefeatTimeout, uint96 fraudSlashingAmount, uint32 fraudNotifierRewardMultiplier) -func (_Bridge *BridgeFilterer) ParseFraudParametersUpdated(log types.Log) (*BridgeFraudParametersUpdated, error) { - event := new(BridgeFraudParametersUpdated) - if err := _Bridge.contract.UnpackLog(event, "FraudParametersUpdated", log); err != nil { +// Solidity: event FrostWalletRegistrySet(address frostWalletRegistry) +func (_Bridge *BridgeFilterer) ParseFrostWalletRegistrySet(log types.Log) (*BridgeFrostWalletRegistrySet, error) { + event := new(BridgeFrostWalletRegistrySet) + if err := _Bridge.contract.UnpackLog(event, "FrostWalletRegistrySet", log); err != nil { return nil, err } event.Raw = log @@ -3454,6 +3647,303 @@ func (_Bridge *BridgeFilterer) ParseInitialized(log types.Log) (*BridgeInitializ return event, nil } +// BridgeLegacyFraudChallengeMigratedIterator is returned from FilterLegacyFraudChallengeMigrated and is used to iterate over the raw logs and unpacked data for LegacyFraudChallengeMigrated events raised by the Bridge contract. +type BridgeLegacyFraudChallengeMigratedIterator struct { + Event *BridgeLegacyFraudChallengeMigrated // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *BridgeLegacyFraudChallengeMigratedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(BridgeLegacyFraudChallengeMigrated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(BridgeLegacyFraudChallengeMigrated) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *BridgeLegacyFraudChallengeMigratedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *BridgeLegacyFraudChallengeMigratedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// BridgeLegacyFraudChallengeMigrated represents a LegacyFraudChallengeMigrated event raised by the Bridge contract. +type BridgeLegacyFraudChallengeMigrated struct { + RouterKind uint8 + ChallengeKey *big.Int + Challenger common.Address + DepositAmount *big.Int + Raw types.Log // Blockchain specific contextual infos +} + +// FilterLegacyFraudChallengeMigrated is a free log retrieval operation binding the contract event 0xef4dd86f5d8e036d15cf4958485bdef0a43da00304fa8ad123bda135dfca8f8f. +// +// Solidity: event LegacyFraudChallengeMigrated(uint8 indexed routerKind, uint256 indexed challengeKey, address indexed challenger, uint256 depositAmount) +func (_Bridge *BridgeFilterer) FilterLegacyFraudChallengeMigrated(opts *bind.FilterOpts, routerKind []uint8, challengeKey []*big.Int, challenger []common.Address) (*BridgeLegacyFraudChallengeMigratedIterator, error) { + + var routerKindRule []interface{} + for _, routerKindItem := range routerKind { + routerKindRule = append(routerKindRule, routerKindItem) + } + var challengeKeyRule []interface{} + for _, challengeKeyItem := range challengeKey { + challengeKeyRule = append(challengeKeyRule, challengeKeyItem) + } + var challengerRule []interface{} + for _, challengerItem := range challenger { + challengerRule = append(challengerRule, challengerItem) + } + + logs, sub, err := _Bridge.contract.FilterLogs(opts, "LegacyFraudChallengeMigrated", routerKindRule, challengeKeyRule, challengerRule) + if err != nil { + return nil, err + } + return &BridgeLegacyFraudChallengeMigratedIterator{contract: _Bridge.contract, event: "LegacyFraudChallengeMigrated", logs: logs, sub: sub}, nil +} + +// WatchLegacyFraudChallengeMigrated is a free log subscription operation binding the contract event 0xef4dd86f5d8e036d15cf4958485bdef0a43da00304fa8ad123bda135dfca8f8f. +// +// Solidity: event LegacyFraudChallengeMigrated(uint8 indexed routerKind, uint256 indexed challengeKey, address indexed challenger, uint256 depositAmount) +func (_Bridge *BridgeFilterer) WatchLegacyFraudChallengeMigrated(opts *bind.WatchOpts, sink chan<- *BridgeLegacyFraudChallengeMigrated, routerKind []uint8, challengeKey []*big.Int, challenger []common.Address) (event.Subscription, error) { + + var routerKindRule []interface{} + for _, routerKindItem := range routerKind { + routerKindRule = append(routerKindRule, routerKindItem) + } + var challengeKeyRule []interface{} + for _, challengeKeyItem := range challengeKey { + challengeKeyRule = append(challengeKeyRule, challengeKeyItem) + } + var challengerRule []interface{} + for _, challengerItem := range challenger { + challengerRule = append(challengerRule, challengerItem) + } + + logs, sub, err := _Bridge.contract.WatchLogs(opts, "LegacyFraudChallengeMigrated", routerKindRule, challengeKeyRule, challengerRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(BridgeLegacyFraudChallengeMigrated) + if err := _Bridge.contract.UnpackLog(event, "LegacyFraudChallengeMigrated", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseLegacyFraudChallengeMigrated is a log parse operation binding the contract event 0xef4dd86f5d8e036d15cf4958485bdef0a43da00304fa8ad123bda135dfca8f8f. +// +// Solidity: event LegacyFraudChallengeMigrated(uint8 indexed routerKind, uint256 indexed challengeKey, address indexed challenger, uint256 depositAmount) +func (_Bridge *BridgeFilterer) ParseLegacyFraudChallengeMigrated(log types.Log) (*BridgeLegacyFraudChallengeMigrated, error) { + event := new(BridgeLegacyFraudChallengeMigrated) + if err := _Bridge.contract.UnpackLog(event, "LegacyFraudChallengeMigrated", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// BridgeLifecycleRouterSetIterator is returned from FilterLifecycleRouterSet and is used to iterate over the raw logs and unpacked data for LifecycleRouterSet events raised by the Bridge contract. +type BridgeLifecycleRouterSetIterator struct { + Event *BridgeLifecycleRouterSet // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *BridgeLifecycleRouterSetIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(BridgeLifecycleRouterSet) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(BridgeLifecycleRouterSet) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *BridgeLifecycleRouterSetIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *BridgeLifecycleRouterSetIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// BridgeLifecycleRouterSet represents a LifecycleRouterSet event raised by the Bridge contract. +type BridgeLifecycleRouterSet struct { + LifecycleRouter common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterLifecycleRouterSet is a free log retrieval operation binding the contract event 0xd34c360c4ba3b0ef69ec75dd2fd413d2432504b21290e9dfdd9d0bffab5376d7. +// +// Solidity: event LifecycleRouterSet(address lifecycleRouter) +func (_Bridge *BridgeFilterer) FilterLifecycleRouterSet(opts *bind.FilterOpts) (*BridgeLifecycleRouterSetIterator, error) { + + logs, sub, err := _Bridge.contract.FilterLogs(opts, "LifecycleRouterSet") + if err != nil { + return nil, err + } + return &BridgeLifecycleRouterSetIterator{contract: _Bridge.contract, event: "LifecycleRouterSet", logs: logs, sub: sub}, nil +} + +// WatchLifecycleRouterSet is a free log subscription operation binding the contract event 0xd34c360c4ba3b0ef69ec75dd2fd413d2432504b21290e9dfdd9d0bffab5376d7. +// +// Solidity: event LifecycleRouterSet(address lifecycleRouter) +func (_Bridge *BridgeFilterer) WatchLifecycleRouterSet(opts *bind.WatchOpts, sink chan<- *BridgeLifecycleRouterSet) (event.Subscription, error) { + + logs, sub, err := _Bridge.contract.WatchLogs(opts, "LifecycleRouterSet") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(BridgeLifecycleRouterSet) + if err := _Bridge.contract.UnpackLog(event, "LifecycleRouterSet", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseLifecycleRouterSet is a log parse operation binding the contract event 0xd34c360c4ba3b0ef69ec75dd2fd413d2432504b21290e9dfdd9d0bffab5376d7. +// +// Solidity: event LifecycleRouterSet(address lifecycleRouter) +func (_Bridge *BridgeFilterer) ParseLifecycleRouterSet(log types.Log) (*BridgeLifecycleRouterSet, error) { + event := new(BridgeLifecycleRouterSet) + if err := _Bridge.contract.UnpackLog(event, "LifecycleRouterSet", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + // BridgeMovedFundsSweepTimedOutIterator is returned from FilterMovedFundsSweepTimedOut and is used to iterate over the raw logs and unpacked data for MovedFundsSweepTimedOut events raised by the Bridge contract. type BridgeMovedFundsSweepTimedOutIterator struct { Event *BridgeMovedFundsSweepTimedOut // Event containing the contract specifics and raw log @@ -4612,9 +5102,9 @@ func (_Bridge *BridgeFilterer) ParseMovingFundsTimeoutReset(log types.Log) (*Bri return event, nil } -// BridgeNewWalletRegisteredIterator is returned from FilterNewWalletRegistered and is used to iterate over the raw logs and unpacked data for NewWalletRegistered events raised by the Bridge contract. -type BridgeNewWalletRegisteredIterator struct { - Event *BridgeNewWalletRegistered // Event containing the contract specifics and raw log +// BridgeNewFrostWalletRegisteredIterator is returned from FilterNewFrostWalletRegistered and is used to iterate over the raw logs and unpacked data for NewFrostWalletRegistered events raised by the Bridge contract. +type BridgeNewFrostWalletRegisteredIterator struct { + Event *BridgeNewFrostWalletRegistered // Event containing the contract specifics and raw log contract *bind.BoundContract // Generic contract to use for unpacking event data event string // Event name to use for unpacking event data @@ -4628,7 +5118,7 @@ type BridgeNewWalletRegisteredIterator struct { // Next advances the iterator to the subsequent event, returning whether there // are any more events found. In case of a retrieval or parsing error, false is // returned and Error() can be queried for the exact failure. -func (it *BridgeNewWalletRegisteredIterator) Next() bool { +func (it *BridgeNewFrostWalletRegisteredIterator) Next() bool { // If the iterator failed, stop iterating if it.fail != nil { return false @@ -4637,7 +5127,7 @@ func (it *BridgeNewWalletRegisteredIterator) Next() bool { if it.done { select { case log := <-it.logs: - it.Event = new(BridgeNewWalletRegistered) + it.Event = new(BridgeNewFrostWalletRegistered) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -4652,7 +5142,7 @@ func (it *BridgeNewWalletRegisteredIterator) Next() bool { // Iterator still in progress, wait for either a data or an error event select { case log := <-it.logs: - it.Event = new(BridgeNewWalletRegistered) + it.Event = new(BridgeNewFrostWalletRegistered) if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { it.fail = err return false @@ -4668,28 +5158,190 @@ func (it *BridgeNewWalletRegisteredIterator) Next() bool { } // Error returns any retrieval or parsing error occurred during filtering. -func (it *BridgeNewWalletRegisteredIterator) Error() error { +func (it *BridgeNewFrostWalletRegisteredIterator) Error() error { return it.fail } // Close terminates the iteration process, releasing any pending underlying // resources. -func (it *BridgeNewWalletRegisteredIterator) Close() error { +func (it *BridgeNewFrostWalletRegisteredIterator) Close() error { it.sub.Unsubscribe() return nil } -// BridgeNewWalletRegistered represents a NewWalletRegistered event raised by the Bridge contract. -type BridgeNewWalletRegistered struct { - EcdsaWalletID [32]byte +// BridgeNewFrostWalletRegistered represents a NewFrostWalletRegistered event raised by the Bridge contract. +type BridgeNewFrostWalletRegistered struct { + WalletID [32]byte WalletPubKeyHash [20]byte + XOnlyOutputKey [32]byte Raw types.Log // Blockchain specific contextual infos } -// FilterNewWalletRegistered is a free log retrieval operation binding the contract event 0x2dbb47dce81d6b11cca1f1e3b10143d6f7e1e7e92d2dd9aacbb1f875379d308e. +// FilterNewFrostWalletRegistered is a free log retrieval operation binding the contract event 0xd9aa9c3636339f9edab116054e0fff7f31ff75da8fb201345c31980bb7644334. // -// Solidity: event NewWalletRegistered(bytes32 indexed ecdsaWalletID, bytes20 indexed walletPubKeyHash) -func (_Bridge *BridgeFilterer) FilterNewWalletRegistered(opts *bind.FilterOpts, ecdsaWalletID [][32]byte, walletPubKeyHash [][20]byte) (*BridgeNewWalletRegisteredIterator, error) { +// Solidity: event NewFrostWalletRegistered(bytes32 indexed walletID, bytes20 indexed walletPubKeyHash, bytes32 indexed xOnlyOutputKey) +func (_Bridge *BridgeFilterer) FilterNewFrostWalletRegistered(opts *bind.FilterOpts, walletID [][32]byte, walletPubKeyHash [][20]byte, xOnlyOutputKey [][32]byte) (*BridgeNewFrostWalletRegisteredIterator, error) { + + var walletIDRule []interface{} + for _, walletIDItem := range walletID { + walletIDRule = append(walletIDRule, walletIDItem) + } + var walletPubKeyHashRule []interface{} + for _, walletPubKeyHashItem := range walletPubKeyHash { + walletPubKeyHashRule = append(walletPubKeyHashRule, walletPubKeyHashItem) + } + var xOnlyOutputKeyRule []interface{} + for _, xOnlyOutputKeyItem := range xOnlyOutputKey { + xOnlyOutputKeyRule = append(xOnlyOutputKeyRule, xOnlyOutputKeyItem) + } + + logs, sub, err := _Bridge.contract.FilterLogs(opts, "NewFrostWalletRegistered", walletIDRule, walletPubKeyHashRule, xOnlyOutputKeyRule) + if err != nil { + return nil, err + } + return &BridgeNewFrostWalletRegisteredIterator{contract: _Bridge.contract, event: "NewFrostWalletRegistered", logs: logs, sub: sub}, nil +} + +// WatchNewFrostWalletRegistered is a free log subscription operation binding the contract event 0xd9aa9c3636339f9edab116054e0fff7f31ff75da8fb201345c31980bb7644334. +// +// Solidity: event NewFrostWalletRegistered(bytes32 indexed walletID, bytes20 indexed walletPubKeyHash, bytes32 indexed xOnlyOutputKey) +func (_Bridge *BridgeFilterer) WatchNewFrostWalletRegistered(opts *bind.WatchOpts, sink chan<- *BridgeNewFrostWalletRegistered, walletID [][32]byte, walletPubKeyHash [][20]byte, xOnlyOutputKey [][32]byte) (event.Subscription, error) { + + var walletIDRule []interface{} + for _, walletIDItem := range walletID { + walletIDRule = append(walletIDRule, walletIDItem) + } + var walletPubKeyHashRule []interface{} + for _, walletPubKeyHashItem := range walletPubKeyHash { + walletPubKeyHashRule = append(walletPubKeyHashRule, walletPubKeyHashItem) + } + var xOnlyOutputKeyRule []interface{} + for _, xOnlyOutputKeyItem := range xOnlyOutputKey { + xOnlyOutputKeyRule = append(xOnlyOutputKeyRule, xOnlyOutputKeyItem) + } + + logs, sub, err := _Bridge.contract.WatchLogs(opts, "NewFrostWalletRegistered", walletIDRule, walletPubKeyHashRule, xOnlyOutputKeyRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(BridgeNewFrostWalletRegistered) + if err := _Bridge.contract.UnpackLog(event, "NewFrostWalletRegistered", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseNewFrostWalletRegistered is a log parse operation binding the contract event 0xd9aa9c3636339f9edab116054e0fff7f31ff75da8fb201345c31980bb7644334. +// +// Solidity: event NewFrostWalletRegistered(bytes32 indexed walletID, bytes20 indexed walletPubKeyHash, bytes32 indexed xOnlyOutputKey) +func (_Bridge *BridgeFilterer) ParseNewFrostWalletRegistered(log types.Log) (*BridgeNewFrostWalletRegistered, error) { + event := new(BridgeNewFrostWalletRegistered) + if err := _Bridge.contract.UnpackLog(event, "NewFrostWalletRegistered", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// BridgeNewWalletRegisteredIterator is returned from FilterNewWalletRegistered and is used to iterate over the raw logs and unpacked data for NewWalletRegistered events raised by the Bridge contract. +type BridgeNewWalletRegisteredIterator struct { + Event *BridgeNewWalletRegistered // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *BridgeNewWalletRegisteredIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(BridgeNewWalletRegistered) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(BridgeNewWalletRegistered) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *BridgeNewWalletRegisteredIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *BridgeNewWalletRegisteredIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// BridgeNewWalletRegistered represents a NewWalletRegistered event raised by the Bridge contract. +type BridgeNewWalletRegistered struct { + EcdsaWalletID [32]byte + WalletPubKeyHash [20]byte + Raw types.Log // Blockchain specific contextual infos +} + +// FilterNewWalletRegistered is a free log retrieval operation binding the contract event 0x2dbb47dce81d6b11cca1f1e3b10143d6f7e1e7e92d2dd9aacbb1f875379d308e. +// +// Solidity: event NewWalletRegistered(bytes32 indexed ecdsaWalletID, bytes20 indexed walletPubKeyHash) +func (_Bridge *BridgeFilterer) FilterNewWalletRegistered(opts *bind.FilterOpts, ecdsaWalletID [][32]byte, walletPubKeyHash [][20]byte) (*BridgeNewWalletRegisteredIterator, error) { var ecdsaWalletIDRule []interface{} for _, ecdsaWalletIDItem := range ecdsaWalletID { @@ -5060,6 +5712,284 @@ func (_Bridge *BridgeFilterer) ParseNewWalletRequested(log types.Log) (*BridgeNe return event, nil } +// BridgeNewWalletSchemeSetIterator is returned from FilterNewWalletSchemeSet and is used to iterate over the raw logs and unpacked data for NewWalletSchemeSet events raised by the Bridge contract. +type BridgeNewWalletSchemeSetIterator struct { + Event *BridgeNewWalletSchemeSet // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *BridgeNewWalletSchemeSetIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(BridgeNewWalletSchemeSet) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(BridgeNewWalletSchemeSet) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *BridgeNewWalletSchemeSetIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *BridgeNewWalletSchemeSetIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// BridgeNewWalletSchemeSet represents a NewWalletSchemeSet event raised by the Bridge contract. +type BridgeNewWalletSchemeSet struct { + Scheme uint8 + Raw types.Log // Blockchain specific contextual infos +} + +// FilterNewWalletSchemeSet is a free log retrieval operation binding the contract event 0xf02f991b885946929457e15df17c468398baff309f97deb150209e448b9157ca. +// +// Solidity: event NewWalletSchemeSet(uint8 indexed scheme) +func (_Bridge *BridgeFilterer) FilterNewWalletSchemeSet(opts *bind.FilterOpts, scheme []uint8) (*BridgeNewWalletSchemeSetIterator, error) { + + var schemeRule []interface{} + for _, schemeItem := range scheme { + schemeRule = append(schemeRule, schemeItem) + } + + logs, sub, err := _Bridge.contract.FilterLogs(opts, "NewWalletSchemeSet", schemeRule) + if err != nil { + return nil, err + } + return &BridgeNewWalletSchemeSetIterator{contract: _Bridge.contract, event: "NewWalletSchemeSet", logs: logs, sub: sub}, nil +} + +// WatchNewWalletSchemeSet is a free log subscription operation binding the contract event 0xf02f991b885946929457e15df17c468398baff309f97deb150209e448b9157ca. +// +// Solidity: event NewWalletSchemeSet(uint8 indexed scheme) +func (_Bridge *BridgeFilterer) WatchNewWalletSchemeSet(opts *bind.WatchOpts, sink chan<- *BridgeNewWalletSchemeSet, scheme []uint8) (event.Subscription, error) { + + var schemeRule []interface{} + for _, schemeItem := range scheme { + schemeRule = append(schemeRule, schemeItem) + } + + logs, sub, err := _Bridge.contract.WatchLogs(opts, "NewWalletSchemeSet", schemeRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(BridgeNewWalletSchemeSet) + if err := _Bridge.contract.UnpackLog(event, "NewWalletSchemeSet", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseNewWalletSchemeSet is a log parse operation binding the contract event 0xf02f991b885946929457e15df17c468398baff309f97deb150209e448b9157ca. +// +// Solidity: event NewWalletSchemeSet(uint8 indexed scheme) +func (_Bridge *BridgeFilterer) ParseNewWalletSchemeSet(log types.Log) (*BridgeNewWalletSchemeSet, error) { + event := new(BridgeNewWalletSchemeSet) + if err := _Bridge.contract.UnpackLog(event, "NewWalletSchemeSet", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + +// BridgeP2TRFraudRouterSetIterator is returned from FilterP2TRFraudRouterSet and is used to iterate over the raw logs and unpacked data for P2TRFraudRouterSet events raised by the Bridge contract. +type BridgeP2TRFraudRouterSetIterator struct { + Event *BridgeP2TRFraudRouterSet // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *BridgeP2TRFraudRouterSetIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(BridgeP2TRFraudRouterSet) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(BridgeP2TRFraudRouterSet) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *BridgeP2TRFraudRouterSetIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *BridgeP2TRFraudRouterSetIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// BridgeP2TRFraudRouterSet represents a P2TRFraudRouterSet event raised by the Bridge contract. +type BridgeP2TRFraudRouterSet struct { + P2trFraudRouter common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterP2TRFraudRouterSet is a free log retrieval operation binding the contract event 0x083fc37b87ed978d63df891a75b6e9ab20e73e33ae9fcab66416b8d014ceee54. +// +// Solidity: event P2TRFraudRouterSet(address p2trFraudRouter) +func (_Bridge *BridgeFilterer) FilterP2TRFraudRouterSet(opts *bind.FilterOpts) (*BridgeP2TRFraudRouterSetIterator, error) { + + logs, sub, err := _Bridge.contract.FilterLogs(opts, "P2TRFraudRouterSet") + if err != nil { + return nil, err + } + return &BridgeP2TRFraudRouterSetIterator{contract: _Bridge.contract, event: "P2TRFraudRouterSet", logs: logs, sub: sub}, nil +} + +// WatchP2TRFraudRouterSet is a free log subscription operation binding the contract event 0x083fc37b87ed978d63df891a75b6e9ab20e73e33ae9fcab66416b8d014ceee54. +// +// Solidity: event P2TRFraudRouterSet(address p2trFraudRouter) +func (_Bridge *BridgeFilterer) WatchP2TRFraudRouterSet(opts *bind.WatchOpts, sink chan<- *BridgeP2TRFraudRouterSet) (event.Subscription, error) { + + logs, sub, err := _Bridge.contract.WatchLogs(opts, "P2TRFraudRouterSet") + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(BridgeP2TRFraudRouterSet) + if err := _Bridge.contract.UnpackLog(event, "P2TRFraudRouterSet", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseP2TRFraudRouterSet is a log parse operation binding the contract event 0x083fc37b87ed978d63df891a75b6e9ab20e73e33ae9fcab66416b8d014ceee54. +// +// Solidity: event P2TRFraudRouterSet(address p2trFraudRouter) +func (_Bridge *BridgeFilterer) ParseP2TRFraudRouterSet(log types.Log) (*BridgeP2TRFraudRouterSet, error) { + event := new(BridgeP2TRFraudRouterSet) + if err := _Bridge.contract.UnpackLog(event, "P2TRFraudRouterSet", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + // BridgeRebateStakingSetIterator is returned from FilterRebateStakingSet and is used to iterate over the raw logs and unpacked data for RebateStakingSet events raised by the Bridge contract. type BridgeRebateStakingSetIterator struct { Event *BridgeRebateStakingSet // Event containing the contract specifics and raw log @@ -6062,6 +6992,170 @@ func (_Bridge *BridgeFilterer) ParseSpvMaintainerStatusUpdated(log types.Log) (* return event, nil } +// BridgeTaprootDepositRevealedIterator is returned from FilterTaprootDepositRevealed and is used to iterate over the raw logs and unpacked data for TaprootDepositRevealed events raised by the Bridge contract. +type BridgeTaprootDepositRevealedIterator struct { + Event *BridgeTaprootDepositRevealed // Event containing the contract specifics and raw log + + contract *bind.BoundContract // Generic contract to use for unpacking event data + event string // Event name to use for unpacking event data + + logs chan types.Log // Log channel receiving the found contract events + sub ethereum.Subscription // Subscription for errors, completion and termination + done bool // Whether the subscription completed delivering logs + fail error // Occurred error to stop iteration +} + +// Next advances the iterator to the subsequent event, returning whether there +// are any more events found. In case of a retrieval or parsing error, false is +// returned and Error() can be queried for the exact failure. +func (it *BridgeTaprootDepositRevealedIterator) Next() bool { + // If the iterator failed, stop iterating + if it.fail != nil { + return false + } + // If the iterator completed, deliver directly whatever's available + if it.done { + select { + case log := <-it.logs: + it.Event = new(BridgeTaprootDepositRevealed) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + default: + return false + } + } + // Iterator still in progress, wait for either a data or an error event + select { + case log := <-it.logs: + it.Event = new(BridgeTaprootDepositRevealed) + if err := it.contract.UnpackLog(it.Event, it.event, log); err != nil { + it.fail = err + return false + } + it.Event.Raw = log + return true + + case err := <-it.sub.Err(): + it.done = true + it.fail = err + return it.Next() + } +} + +// Error returns any retrieval or parsing error occurred during filtering. +func (it *BridgeTaprootDepositRevealedIterator) Error() error { + return it.fail +} + +// Close terminates the iteration process, releasing any pending underlying +// resources. +func (it *BridgeTaprootDepositRevealedIterator) Close() error { + it.sub.Unsubscribe() + return nil +} + +// BridgeTaprootDepositRevealed represents a TaprootDepositRevealed event raised by the Bridge contract. +type BridgeTaprootDepositRevealed struct { + FundingTxHash [32]byte + FundingOutputIndex uint32 + Depositor common.Address + Amount uint64 + BlindingFactor [8]byte + WalletPubKeyHash [20]byte + WalletXOnlyPublicKey [32]byte + RefundPubKeyHash [20]byte + RefundXOnlyPublicKey [32]byte + RefundLocktime [4]byte + Vault common.Address + Raw types.Log // Blockchain specific contextual infos +} + +// FilterTaprootDepositRevealed is a free log retrieval operation binding the contract event 0x50a25b08826caa8347dba14b236afbf87a8988553a910cbc953f1a53585d94cf. +// +// Solidity: event TaprootDepositRevealed(bytes32 fundingTxHash, uint32 fundingOutputIndex, address indexed depositor, uint64 amount, bytes8 blindingFactor, bytes20 indexed walletPubKeyHash, bytes32 walletXOnlyPublicKey, bytes20 refundPubKeyHash, bytes32 refundXOnlyPublicKey, bytes4 refundLocktime, address vault) +func (_Bridge *BridgeFilterer) FilterTaprootDepositRevealed(opts *bind.FilterOpts, depositor []common.Address, walletPubKeyHash [][20]byte) (*BridgeTaprootDepositRevealedIterator, error) { + + var depositorRule []interface{} + for _, depositorItem := range depositor { + depositorRule = append(depositorRule, depositorItem) + } + + var walletPubKeyHashRule []interface{} + for _, walletPubKeyHashItem := range walletPubKeyHash { + walletPubKeyHashRule = append(walletPubKeyHashRule, walletPubKeyHashItem) + } + + logs, sub, err := _Bridge.contract.FilterLogs(opts, "TaprootDepositRevealed", depositorRule, walletPubKeyHashRule) + if err != nil { + return nil, err + } + return &BridgeTaprootDepositRevealedIterator{contract: _Bridge.contract, event: "TaprootDepositRevealed", logs: logs, sub: sub}, nil +} + +// WatchTaprootDepositRevealed is a free log subscription operation binding the contract event 0x50a25b08826caa8347dba14b236afbf87a8988553a910cbc953f1a53585d94cf. +// +// Solidity: event TaprootDepositRevealed(bytes32 fundingTxHash, uint32 fundingOutputIndex, address indexed depositor, uint64 amount, bytes8 blindingFactor, bytes20 indexed walletPubKeyHash, bytes32 walletXOnlyPublicKey, bytes20 refundPubKeyHash, bytes32 refundXOnlyPublicKey, bytes4 refundLocktime, address vault) +func (_Bridge *BridgeFilterer) WatchTaprootDepositRevealed(opts *bind.WatchOpts, sink chan<- *BridgeTaprootDepositRevealed, depositor []common.Address, walletPubKeyHash [][20]byte) (event.Subscription, error) { + + var depositorRule []interface{} + for _, depositorItem := range depositor { + depositorRule = append(depositorRule, depositorItem) + } + + var walletPubKeyHashRule []interface{} + for _, walletPubKeyHashItem := range walletPubKeyHash { + walletPubKeyHashRule = append(walletPubKeyHashRule, walletPubKeyHashItem) + } + + logs, sub, err := _Bridge.contract.WatchLogs(opts, "TaprootDepositRevealed", depositorRule, walletPubKeyHashRule) + if err != nil { + return nil, err + } + return event.NewSubscription(func(quit <-chan struct{}) error { + defer sub.Unsubscribe() + for { + select { + case log := <-logs: + // New log arrived, parse the event and forward to the user + event := new(BridgeTaprootDepositRevealed) + if err := _Bridge.contract.UnpackLog(event, "TaprootDepositRevealed", log); err != nil { + return err + } + event.Raw = log + + select { + case sink <- event: + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + case err := <-sub.Err(): + return err + case <-quit: + return nil + } + } + }), nil +} + +// ParseTaprootDepositRevealed is a log parse operation binding the contract event 0x50a25b08826caa8347dba14b236afbf87a8988553a910cbc953f1a53585d94cf. +// +// Solidity: event TaprootDepositRevealed(bytes32 fundingTxHash, uint32 fundingOutputIndex, address indexed depositor, uint64 amount, bytes8 blindingFactor, bytes20 indexed walletPubKeyHash, bytes32 walletXOnlyPublicKey, bytes20 refundPubKeyHash, bytes32 refundXOnlyPublicKey, bytes4 refundLocktime, address vault) +func (_Bridge *BridgeFilterer) ParseTaprootDepositRevealed(log types.Log) (*BridgeTaprootDepositRevealed, error) { + event := new(BridgeTaprootDepositRevealed) + if err := _Bridge.contract.UnpackLog(event, "TaprootDepositRevealed", log); err != nil { + return nil, err + } + event.Raw = log + return event, nil +} + // BridgeTreasuryUpdatedIterator is returned from FilterTreasuryUpdated and is used to iterate over the raw logs and unpacked data for TreasuryUpdated events raised by the Bridge contract. type BridgeTreasuryUpdatedIterator struct { Event *BridgeTreasuryUpdated // Event containing the contract specifics and raw log diff --git a/pkg/chain/ethereum/tbtc/gen/abi/WalletProposalValidator.go b/pkg/chain/ethereum/tbtc/gen/abi/WalletProposalValidator.go index ed86d98785..21f79319ba 100644 --- a/pkg/chain/ethereum/tbtc/gen/abi/WalletProposalValidator.go +++ b/pkg/chain/ethereum/tbtc/gen/abi/WalletProposalValidator.go @@ -95,9 +95,20 @@ type WalletProposalValidatorRedemptionProposal struct { RedemptionTxFee *big.Int } +// WalletProposalValidatorTaprootDepositExtraInfo is an auto generated low-level Go binding around an user-defined struct. +type WalletProposalValidatorTaprootDepositExtraInfo struct { + FundingTx BitcoinTxInfo2 + BlindingFactor [8]byte + WalletPubKeyHash [20]byte + WalletXOnlyPublicKey [32]byte + RefundPubKeyHash [20]byte + RefundXOnlyPublicKey [32]byte + RefundLocktime [4]byte +} + // WalletProposalValidatorMetaData contains all meta data concerning the WalletProposalValidator contract. var WalletProposalValidatorMetaData = &bind.MetaData{ - ABI: "[{\"inputs\":[{\"internalType\":\"contractBridge\",\"name\":\"_bridge\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"DEPOSIT_MIN_AGE\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"DEPOSIT_REFUND_SAFETY_MARGIN\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"DEPOSIT_SWEEP_MAX_SIZE\",\"outputs\":[{\"internalType\":\"uint16\",\"name\":\"\",\"type\":\"uint16\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"REDEMPTION_MAX_SIZE\",\"outputs\":[{\"internalType\":\"uint16\",\"name\":\"\",\"type\":\"uint16\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"REDEMPTION_REQUEST_MIN_AGE\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"REDEMPTION_REQUEST_TIMEOUT_SAFETY_MARGIN\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"bridge\",\"outputs\":[{\"internalType\":\"contractBridge\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"fundingTxHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"fundingOutputIndex\",\"type\":\"uint32\"}],\"internalType\":\"structWalletProposalValidator.DepositKey[]\",\"name\":\"depositsKeys\",\"type\":\"tuple[]\"},{\"internalType\":\"uint256\",\"name\":\"sweepTxFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256[]\",\"name\":\"depositsRevealBlocks\",\"type\":\"uint256[]\"}],\"internalType\":\"structWalletProposalValidator.DepositSweepProposal\",\"name\":\"proposal\",\"type\":\"tuple\"},{\"components\":[{\"components\":[{\"internalType\":\"bytes4\",\"name\":\"version\",\"type\":\"bytes4\"},{\"internalType\":\"bytes\",\"name\":\"inputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"outputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes4\",\"name\":\"locktime\",\"type\":\"bytes4\"}],\"internalType\":\"structBitcoinTx.Info\",\"name\":\"fundingTx\",\"type\":\"tuple\"},{\"internalType\":\"bytes8\",\"name\":\"blindingFactor\",\"type\":\"bytes8\"},{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes20\",\"name\":\"refundPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes4\",\"name\":\"refundLocktime\",\"type\":\"bytes4\"}],\"internalType\":\"structWalletProposalValidator.DepositExtraInfo[]\",\"name\":\"depositsExtraInfo\",\"type\":\"tuple[]\"}],\"name\":\"validateDepositSweepProposal\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"internalType\":\"structWalletProposalValidator.HeartbeatProposal\",\"name\":\"proposal\",\"type\":\"tuple\"}],\"name\":\"validateHeartbeatProposal\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes32\",\"name\":\"movingFundsTxHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"movingFundsTxOutputIndex\",\"type\":\"uint32\"},{\"internalType\":\"uint256\",\"name\":\"movedFundsSweepTxFee\",\"type\":\"uint256\"}],\"internalType\":\"structWalletProposalValidator.MovedFundsSweepProposal\",\"name\":\"proposal\",\"type\":\"tuple\"}],\"name\":\"validateMovedFundsSweepProposal\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes20[]\",\"name\":\"targetWallets\",\"type\":\"bytes20[]\"},{\"internalType\":\"uint256\",\"name\":\"movingFundsTxFee\",\"type\":\"uint256\"}],\"internalType\":\"structWalletProposalValidator.MovingFundsProposal\",\"name\":\"proposal\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"txHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"txOutputIndex\",\"type\":\"uint32\"},{\"internalType\":\"uint64\",\"name\":\"txOutputValue\",\"type\":\"uint64\"}],\"internalType\":\"structBitcoinTx.UTXO\",\"name\":\"walletMainUtxo\",\"type\":\"tuple\"}],\"name\":\"validateMovingFundsProposal\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes[]\",\"name\":\"redeemersOutputScripts\",\"type\":\"bytes[]\"},{\"internalType\":\"uint256\",\"name\":\"redemptionTxFee\",\"type\":\"uint256\"}],\"internalType\":\"structWalletProposalValidator.RedemptionProposal\",\"name\":\"proposal\",\"type\":\"tuple\"}],\"name\":\"validateRedemptionProposal\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", + ABI: "[{\"inputs\":[{\"internalType\":\"contractBridge\",\"name\":\"_bridge\",\"type\":\"address\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"inputs\":[],\"name\":\"DEPOSIT_MIN_AGE\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"DEPOSIT_REFUND_SAFETY_MARGIN\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"DEPOSIT_SWEEP_MAX_SIZE\",\"outputs\":[{\"internalType\":\"uint16\",\"name\":\"\",\"type\":\"uint16\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"REDEMPTION_MAX_SIZE\",\"outputs\":[{\"internalType\":\"uint16\",\"name\":\"\",\"type\":\"uint16\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"REDEMPTION_REQUEST_MIN_AGE\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"REDEMPTION_REQUEST_TIMEOUT_SAFETY_MARGIN\",\"outputs\":[{\"internalType\":\"uint32\",\"name\":\"\",\"type\":\"uint32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"bridge\",\"outputs\":[{\"internalType\":\"contractBridge\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"fundingTxHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"fundingOutputIndex\",\"type\":\"uint32\"}],\"internalType\":\"structWalletProposalValidator.DepositKey[]\",\"name\":\"depositsKeys\",\"type\":\"tuple[]\"},{\"internalType\":\"uint256\",\"name\":\"sweepTxFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256[]\",\"name\":\"depositsRevealBlocks\",\"type\":\"uint256[]\"}],\"internalType\":\"structWalletProposalValidator.DepositSweepProposal\",\"name\":\"proposal\",\"type\":\"tuple\"},{\"components\":[{\"components\":[{\"internalType\":\"bytes4\",\"name\":\"version\",\"type\":\"bytes4\"},{\"internalType\":\"bytes\",\"name\":\"inputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"outputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes4\",\"name\":\"locktime\",\"type\":\"bytes4\"}],\"internalType\":\"structBitcoinTx.Info\",\"name\":\"fundingTx\",\"type\":\"tuple\"},{\"internalType\":\"bytes8\",\"name\":\"blindingFactor\",\"type\":\"bytes8\"},{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes20\",\"name\":\"refundPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes4\",\"name\":\"refundLocktime\",\"type\":\"bytes4\"}],\"internalType\":\"structWalletProposalValidator.DepositExtraInfo[]\",\"name\":\"depositsExtraInfo\",\"type\":\"tuple[]\"}],\"name\":\"validateDepositSweepProposal\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes\",\"name\":\"message\",\"type\":\"bytes\"}],\"internalType\":\"structWalletProposalValidator.HeartbeatProposal\",\"name\":\"proposal\",\"type\":\"tuple\"}],\"name\":\"validateHeartbeatProposal\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes32\",\"name\":\"movingFundsTxHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"movingFundsTxOutputIndex\",\"type\":\"uint32\"},{\"internalType\":\"uint256\",\"name\":\"movedFundsSweepTxFee\",\"type\":\"uint256\"}],\"internalType\":\"structWalletProposalValidator.MovedFundsSweepProposal\",\"name\":\"proposal\",\"type\":\"tuple\"}],\"name\":\"validateMovedFundsSweepProposal\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes20[]\",\"name\":\"targetWallets\",\"type\":\"bytes20[]\"},{\"internalType\":\"uint256\",\"name\":\"movingFundsTxFee\",\"type\":\"uint256\"}],\"internalType\":\"structWalletProposalValidator.MovingFundsProposal\",\"name\":\"proposal\",\"type\":\"tuple\"},{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"txHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"txOutputIndex\",\"type\":\"uint32\"},{\"internalType\":\"uint64\",\"name\":\"txOutputValue\",\"type\":\"uint64\"}],\"internalType\":\"structBitcoinTx.UTXO\",\"name\":\"walletMainUtxo\",\"type\":\"tuple\"}],\"name\":\"validateMovingFundsProposal\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes[]\",\"name\":\"redeemersOutputScripts\",\"type\":\"bytes[]\"},{\"internalType\":\"uint256\",\"name\":\"redemptionTxFee\",\"type\":\"uint256\"}],\"internalType\":\"structWalletProposalValidator.RedemptionProposal\",\"name\":\"proposal\",\"type\":\"tuple\"}],\"name\":\"validateRedemptionProposal\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"components\":[{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"components\":[{\"internalType\":\"bytes32\",\"name\":\"fundingTxHash\",\"type\":\"bytes32\"},{\"internalType\":\"uint32\",\"name\":\"fundingOutputIndex\",\"type\":\"uint32\"}],\"internalType\":\"structWalletProposalValidator.DepositKey[]\",\"name\":\"depositsKeys\",\"type\":\"tuple[]\"},{\"internalType\":\"uint256\",\"name\":\"sweepTxFee\",\"type\":\"uint256\"},{\"internalType\":\"uint256[]\",\"name\":\"depositsRevealBlocks\",\"type\":\"uint256[]\"}],\"internalType\":\"structWalletProposalValidator.DepositSweepProposal\",\"name\":\"proposal\",\"type\":\"tuple\"},{\"components\":[{\"components\":[{\"internalType\":\"bytes4\",\"name\":\"version\",\"type\":\"bytes4\"},{\"internalType\":\"bytes\",\"name\":\"inputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes\",\"name\":\"outputVector\",\"type\":\"bytes\"},{\"internalType\":\"bytes4\",\"name\":\"locktime\",\"type\":\"bytes4\"}],\"internalType\":\"structBitcoinTx.Info\",\"name\":\"fundingTx\",\"type\":\"tuple\"},{\"internalType\":\"bytes8\",\"name\":\"blindingFactor\",\"type\":\"bytes8\"},{\"internalType\":\"bytes20\",\"name\":\"walletPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes32\",\"name\":\"walletXOnlyPublicKey\",\"type\":\"bytes32\"},{\"internalType\":\"bytes20\",\"name\":\"refundPubKeyHash\",\"type\":\"bytes20\"},{\"internalType\":\"bytes32\",\"name\":\"refundXOnlyPublicKey\",\"type\":\"bytes32\"},{\"internalType\":\"bytes4\",\"name\":\"refundLocktime\",\"type\":\"bytes4\"}],\"internalType\":\"structWalletProposalValidator.TaprootDepositExtraInfo[]\",\"name\":\"depositsExtraInfo\",\"type\":\"tuple[]\"}],\"name\":\"validateTaprootDepositSweepProposal\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"view\",\"type\":\"function\"}]", } // WalletProposalValidatorABI is the input ABI used to generate the binding from. @@ -617,3 +628,34 @@ func (_WalletProposalValidator *WalletProposalValidatorSession) ValidateRedempti func (_WalletProposalValidator *WalletProposalValidatorCallerSession) ValidateRedemptionProposal(proposal WalletProposalValidatorRedemptionProposal) (bool, error) { return _WalletProposalValidator.Contract.ValidateRedemptionProposal(&_WalletProposalValidator.CallOpts, proposal) } + +// ValidateTaprootDepositSweepProposal is a free data retrieval call binding the contract method 0xb1782302. +// +// Solidity: function validateTaprootDepositSweepProposal((bytes20,(bytes32,uint32)[],uint256,uint256[]) proposal, ((bytes4,bytes,bytes,bytes4),bytes8,bytes20,bytes32,bytes20,bytes32,bytes4)[] depositsExtraInfo) view returns(bool) +func (_WalletProposalValidator *WalletProposalValidatorCaller) ValidateTaprootDepositSweepProposal(opts *bind.CallOpts, proposal WalletProposalValidatorDepositSweepProposal, depositsExtraInfo []WalletProposalValidatorTaprootDepositExtraInfo) (bool, error) { + var out []interface{} + err := _WalletProposalValidator.contract.Call(opts, &out, "validateTaprootDepositSweepProposal", proposal, depositsExtraInfo) + + if err != nil { + return *new(bool), err + } + + out0 := *abi.ConvertType(out[0], new(bool)).(*bool) + + return out0, err + +} + +// ValidateTaprootDepositSweepProposal is a free data retrieval call binding the contract method 0xb1782302. +// +// Solidity: function validateTaprootDepositSweepProposal((bytes20,(bytes32,uint32)[],uint256,uint256[]) proposal, ((bytes4,bytes,bytes,bytes4),bytes8,bytes20,bytes32,bytes20,bytes32,bytes4)[] depositsExtraInfo) view returns(bool) +func (_WalletProposalValidator *WalletProposalValidatorSession) ValidateTaprootDepositSweepProposal(proposal WalletProposalValidatorDepositSweepProposal, depositsExtraInfo []WalletProposalValidatorTaprootDepositExtraInfo) (bool, error) { + return _WalletProposalValidator.Contract.ValidateTaprootDepositSweepProposal(&_WalletProposalValidator.CallOpts, proposal, depositsExtraInfo) +} + +// ValidateTaprootDepositSweepProposal is a free data retrieval call binding the contract method 0xb1782302. +// +// Solidity: function validateTaprootDepositSweepProposal((bytes20,(bytes32,uint32)[],uint256,uint256[]) proposal, ((bytes4,bytes,bytes,bytes4),bytes8,bytes20,bytes32,bytes20,bytes32,bytes4)[] depositsExtraInfo) view returns(bool) +func (_WalletProposalValidator *WalletProposalValidatorCallerSession) ValidateTaprootDepositSweepProposal(proposal WalletProposalValidatorDepositSweepProposal, depositsExtraInfo []WalletProposalValidatorTaprootDepositExtraInfo) (bool, error) { + return _WalletProposalValidator.Contract.ValidateTaprootDepositSweepProposal(&_WalletProposalValidator.CallOpts, proposal, depositsExtraInfo) +} diff --git a/pkg/chain/ethereum/tbtc/gen/cmd/Bridge.go b/pkg/chain/ethereum/tbtc/gen/cmd/Bridge.go index 5af214163a..058deabc58 100644 --- a/pkg/chain/ethereum/tbtc/gen/cmd/Bridge.go +++ b/pkg/chain/ethereum/tbtc/gen/cmd/Bridge.go @@ -57,8 +57,10 @@ func init() { bContractReferencesCommand(), bDepositParametersCommand(), bDepositsCommand(), - bFraudChallengesCommand(), + bEcdsaFraudRouterCommand(), + bEcdsaRetiredCommand(), bFraudParametersCommand(), + bFrostLifecycleContextCommand(), bGetRebateStakingCommand(), bGetRedemptionWatchtowerCommand(), bGovernanceCommand(), @@ -66,6 +68,7 @@ func init() { bLiveWalletsCountCommand(), bMovedFundsSweepRequestsCommand(), bMovingFundsParametersCommand(), + bP2trFraudRouterCommand(), bPendingRedemptionsCommand(), bRedemptionParametersCommand(), bSpentMainUTXOsCommand(), @@ -77,10 +80,8 @@ func init() { bWalletPubKeyHashForWalletIDCommand(), bWalletsCommand(), bWalletsByWalletIDCommand(), - bDefeatFraudChallengeCommand(), - bDefeatFraudChallengeWithHeartbeatCommand(), - bEcdsaWalletCreatedCallbackCommand(), bEcdsaWalletHeartbeatFailedCallbackCommand(), + bFrostWalletCreatedCallbackCommand(), bInitializeCommand(), bInitializeV2FixVaultZeroDepositCommand(), bNotifyMovingFundsBelowDustCommand(), @@ -91,14 +92,20 @@ func init() { bRequestNewWalletCommand(), bRequestRedemptionCommand(), bResetMovingFundsTimeoutCommand(), + bRetireEcdsaCommand(), bRevealDepositCommand(), bRevealDepositWithExtraDataCommand(), + bRevealTaprootDepositCommand(), + bRevealTaprootDepositWithExtraDataCommand(), + bSetEcdsaFraudRouterCommand(), + bSetFrostWalletRegistryCommand(), + bSetLifecycleRouterCommand(), + bSetP2TRFraudRouterCommand(), bSetRebateStakingCommand(), bSetRedemptionWatchtowerCommand(), bSetSpvMaintainerStatusCommand(), bSetVaultStatusCommand(), bSubmitDepositSweepProofCommand(), - bSubmitFraudChallengeCommand(), bSubmitMovedFundsSweepProofCommand(), bSubmitMovingFundsProofCommand(), bSubmitRedemptionProofCommand(), @@ -295,12 +302,12 @@ func bDeposits(c *cobra.Command, args []string) error { return nil } -func bFraudChallengesCommand() *cobra.Command { +func bEcdsaFraudRouterCommand() *cobra.Command { c := &cobra.Command{ - Use: "fraud-challenges [arg_challengeKey]", - Short: "Calls the view method fraudChallenges on the Bridge contract.", - Args: cmd.ArgCountChecker(1), - RunE: bFraudChallenges, + Use: "ecdsa-fraud-router", + Short: "Calls the view method ecdsaFraudRouter on the Bridge contract.", + Args: cmd.ArgCountChecker(0), + RunE: bEcdsaFraudRouter, SilenceUsage: true, DisableFlagsInUseLine: true, } @@ -310,22 +317,47 @@ func bFraudChallengesCommand() *cobra.Command { return c } -func bFraudChallenges(c *cobra.Command, args []string) error { +func bEcdsaFraudRouter(c *cobra.Command, args []string) error { contract, err := initializeBridge(c) if err != nil { return err } - arg_challengeKey, err := hexutil.DecodeBig(args[0]) + result, err := contract.EcdsaFraudRouterAtBlock( + cmd.BlockFlagValue.Int, + ) + if err != nil { - return fmt.Errorf( - "couldn't parse parameter arg_challengeKey, a uint256, from passed value %v", - args[0], - ) + return err + } + + cmd.PrintOutput(result) + + return nil +} + +func bEcdsaRetiredCommand() *cobra.Command { + c := &cobra.Command{ + Use: "ecdsa-retired", + Short: "Calls the view method ecdsaRetired on the Bridge contract.", + Args: cmd.ArgCountChecker(0), + RunE: bEcdsaRetired, + SilenceUsage: true, + DisableFlagsInUseLine: true, + } + + cmd.InitConstFlags(c) + + return c +} + +func bEcdsaRetired(c *cobra.Command, args []string) error { + contract, err := initializeBridge(c) + if err != nil { + return err } - result, err := contract.FraudChallengesAtBlock( - arg_challengeKey, + result, err := contract.EcdsaRetiredAtBlock( cmd.BlockFlagValue.Int, ) @@ -372,6 +404,49 @@ func bFraudParameters(c *cobra.Command, args []string) error { return nil } +func bFrostLifecycleContextCommand() *cobra.Command { + c := &cobra.Command{ + Use: "frost-lifecycle-context [arg_walletPubKeyHash]", + Short: "Calls the view method frostLifecycleContext on the Bridge contract.", + Args: cmd.ArgCountChecker(1), + RunE: bFrostLifecycleContext, + SilenceUsage: true, + DisableFlagsInUseLine: true, + } + + cmd.InitConstFlags(c) + + return c +} + +func bFrostLifecycleContext(c *cobra.Command, args []string) error { + contract, err := initializeBridge(c) + if err != nil { + return err + } + + arg_walletPubKeyHash, err := decode.ParseBytes20(args[0]) + if err != nil { + return fmt.Errorf( + "couldn't parse parameter arg_walletPubKeyHash, a bytes20, from passed value %v", + args[0], + ) + } + + result, err := contract.FrostLifecycleContextAtBlock( + arg_walletPubKeyHash, + cmd.BlockFlagValue.Int, + ) + + if err != nil { + return err + } + + cmd.PrintOutput(result) + + return nil +} + func bGetRebateStakingCommand() *cobra.Command { c := &cobra.Command{ Use: "get-rebate-staking", @@ -628,6 +703,40 @@ func bMovingFundsParameters(c *cobra.Command, args []string) error { return nil } +func bP2trFraudRouterCommand() *cobra.Command { + c := &cobra.Command{ + Use: "p2tr-fraud-router", + Short: "Calls the view method p2trFraudRouter on the Bridge contract.", + Args: cmd.ArgCountChecker(0), + RunE: bP2trFraudRouter, + SilenceUsage: true, + DisableFlagsInUseLine: true, + } + + cmd.InitConstFlags(c) + + return c +} + +func bP2trFraudRouter(c *cobra.Command, args []string) error { + contract, err := initializeBridge(c) + if err != nil { + return err + } + + result, err := contract.P2trFraudRouterAtBlock( + cmd.BlockFlagValue.Int, + ) + + if err != nil { + return err + } + + cmd.PrintOutput(result) + + return nil +} + func bPendingRedemptionsCommand() *cobra.Command { c := &cobra.Command{ Use: "pending-redemptions [arg_redemptionKey]", @@ -862,7 +971,7 @@ func bTxProofDifficultyFactor(c *cobra.Command, args []string) error { func bWalletIDCommand() *cobra.Command { c := &cobra.Command{ Use: "wallet-i-d [arg_walletPubKeyHash]", - Short: "Calls the pure method walletID on the Bridge contract.", + Short: "Calls the view method walletID on the Bridge contract.", Args: cmd.ArgCountChecker(1), RunE: bWalletID, SilenceUsage: true, @@ -1067,12 +1176,12 @@ func bWalletsByWalletID(c *cobra.Command, args []string) error { /// ------------------- Non-const methods ------------------- -func bDefeatFraudChallengeCommand() *cobra.Command { +func bEcdsaWalletHeartbeatFailedCallbackCommand() *cobra.Command { c := &cobra.Command{ - Use: "defeat-fraud-challenge [arg_walletPublicKey] [arg_preimage] [arg_witness]", - Short: "Calls the nonpayable method defeatFraudChallenge on the Bridge contract.", + Use: "ecdsa-wallet-heartbeat-failed-callback [arg0] [arg_publicKeyX] [arg_publicKeyY]", + Short: "Calls the nonpayable method ecdsaWalletHeartbeatFailedCallback on the Bridge contract.", Args: cmd.ArgCountChecker(3), - RunE: bDefeatFraudChallenge, + RunE: bEcdsaWalletHeartbeatFailedCallback, SilenceUsage: true, DisableFlagsInUseLine: true, } @@ -1083,30 +1192,30 @@ func bDefeatFraudChallengeCommand() *cobra.Command { return c } -func bDefeatFraudChallenge(c *cobra.Command, args []string) error { +func bEcdsaWalletHeartbeatFailedCallback(c *cobra.Command, args []string) error { contract, err := initializeBridge(c) if err != nil { return err } - arg_walletPublicKey, err := hexutil.Decode(args[0]) + arg0, err := decode.ParseBytes32(args[0]) if err != nil { return fmt.Errorf( - "couldn't parse parameter arg_walletPublicKey, a bytes, from passed value %v", + "couldn't parse parameter arg0, a bytes32, from passed value %v", args[0], ) } - arg_preimage, err := hexutil.Decode(args[1]) + arg_publicKeyX, err := decode.ParseBytes32(args[1]) if err != nil { return fmt.Errorf( - "couldn't parse parameter arg_preimage, a bytes, from passed value %v", + "couldn't parse parameter arg_publicKeyX, a bytes32, from passed value %v", args[1], ) } - arg_witness, err := strconv.ParseBool(args[2]) + arg_publicKeyY, err := decode.ParseBytes32(args[2]) if err != nil { return fmt.Errorf( - "couldn't parse parameter arg_witness, a bool, from passed value %v", + "couldn't parse parameter arg_publicKeyY, a bytes32, from passed value %v", args[2], ) } @@ -1117,10 +1226,10 @@ func bDefeatFraudChallenge(c *cobra.Command, args []string) error { if shouldSubmit, _ := c.Flags().GetBool(cmd.SubmitFlag); shouldSubmit { // Do a regular submission. Take payable into account. - transaction, err = contract.DefeatFraudChallenge( - arg_walletPublicKey, - arg_preimage, - arg_witness, + transaction, err = contract.EcdsaWalletHeartbeatFailedCallback( + arg0, + arg_publicKeyX, + arg_publicKeyY, ) if err != nil { return err @@ -1129,10 +1238,10 @@ func bDefeatFraudChallenge(c *cobra.Command, args []string) error { cmd.PrintOutput(transaction.Hash()) } else { // Do a call. - err = contract.CallDefeatFraudChallenge( - arg_walletPublicKey, - arg_preimage, - arg_witness, + err = contract.CallEcdsaWalletHeartbeatFailedCallback( + arg0, + arg_publicKeyX, + arg_publicKeyY, cmd.BlockFlagValue.Int, ) if err != nil { @@ -1150,12 +1259,12 @@ func bDefeatFraudChallenge(c *cobra.Command, args []string) error { return nil } -func bDefeatFraudChallengeWithHeartbeatCommand() *cobra.Command { +func bFrostWalletCreatedCallbackCommand() *cobra.Command { c := &cobra.Command{ - Use: "defeat-fraud-challenge-with-heartbeat [arg_walletPublicKey] [arg_heartbeatMessage]", - Short: "Calls the nonpayable method defeatFraudChallengeWithHeartbeat on the Bridge contract.", - Args: cmd.ArgCountChecker(2), - RunE: bDefeatFraudChallengeWithHeartbeat, + Use: "frost-wallet-created-callback [arg_xOnlyOutputKey]", + Short: "Calls the nonpayable method frostWalletCreatedCallback on the Bridge contract.", + Args: cmd.ArgCountChecker(1), + RunE: bFrostWalletCreatedCallback, SilenceUsage: true, DisableFlagsInUseLine: true, } @@ -1166,26 +1275,19 @@ func bDefeatFraudChallengeWithHeartbeatCommand() *cobra.Command { return c } -func bDefeatFraudChallengeWithHeartbeat(c *cobra.Command, args []string) error { +func bFrostWalletCreatedCallback(c *cobra.Command, args []string) error { contract, err := initializeBridge(c) if err != nil { return err } - arg_walletPublicKey, err := hexutil.Decode(args[0]) + arg_xOnlyOutputKey, err := decode.ParseBytes32(args[0]) if err != nil { return fmt.Errorf( - "couldn't parse parameter arg_walletPublicKey, a bytes, from passed value %v", + "couldn't parse parameter arg_xOnlyOutputKey, a bytes32, from passed value %v", args[0], ) } - arg_heartbeatMessage, err := hexutil.Decode(args[1]) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter arg_heartbeatMessage, a bytes, from passed value %v", - args[1], - ) - } var ( transaction *types.Transaction @@ -1193,9 +1295,8 @@ func bDefeatFraudChallengeWithHeartbeat(c *cobra.Command, args []string) error { if shouldSubmit, _ := c.Flags().GetBool(cmd.SubmitFlag); shouldSubmit { // Do a regular submission. Take payable into account. - transaction, err = contract.DefeatFraudChallengeWithHeartbeat( - arg_walletPublicKey, - arg_heartbeatMessage, + transaction, err = contract.FrostWalletCreatedCallback( + arg_xOnlyOutputKey, ) if err != nil { return err @@ -1204,9 +1305,8 @@ func bDefeatFraudChallengeWithHeartbeat(c *cobra.Command, args []string) error { cmd.PrintOutput(transaction.Hash()) } else { // Do a call. - err = contract.CallDefeatFraudChallengeWithHeartbeat( - arg_walletPublicKey, - arg_heartbeatMessage, + err = contract.CallFrostWalletCreatedCallback( + arg_xOnlyOutputKey, cmd.BlockFlagValue.Int, ) if err != nil { @@ -1224,12 +1324,12 @@ func bDefeatFraudChallengeWithHeartbeat(c *cobra.Command, args []string) error { return nil } -func bEcdsaWalletCreatedCallbackCommand() *cobra.Command { +func bInitializeCommand() *cobra.Command { c := &cobra.Command{ - Use: "ecdsa-wallet-created-callback [arg_ecdsaWalletID] [arg_publicKeyX] [arg_publicKeyY]", - Short: "Calls the nonpayable method ecdsaWalletCreatedCallback on the Bridge contract.", - Args: cmd.ArgCountChecker(3), - RunE: bEcdsaWalletCreatedCallback, + Use: "initialize [arg__bank] [arg__relay] [arg__treasury] [arg__ecdsaWalletRegistry] [arg__reimbursementPool] [arg__txProofDifficultyFactor]", + Short: "Calls the nonpayable method initialize on the Bridge contract.", + Args: cmd.ArgCountChecker(6), + RunE: bInitialize, SilenceUsage: true, DisableFlagsInUseLine: true, } @@ -1240,33 +1340,54 @@ func bEcdsaWalletCreatedCallbackCommand() *cobra.Command { return c } -func bEcdsaWalletCreatedCallback(c *cobra.Command, args []string) error { +func bInitialize(c *cobra.Command, args []string) error { contract, err := initializeBridge(c) if err != nil { return err } - arg_ecdsaWalletID, err := decode.ParseBytes32(args[0]) + arg__bank, err := chainutil.AddressFromHex(args[0]) if err != nil { return fmt.Errorf( - "couldn't parse parameter arg_ecdsaWalletID, a bytes32, from passed value %v", + "couldn't parse parameter arg__bank, a address, from passed value %v", args[0], ) } - arg_publicKeyX, err := decode.ParseBytes32(args[1]) + arg__relay, err := chainutil.AddressFromHex(args[1]) if err != nil { return fmt.Errorf( - "couldn't parse parameter arg_publicKeyX, a bytes32, from passed value %v", + "couldn't parse parameter arg__relay, a address, from passed value %v", args[1], ) } - arg_publicKeyY, err := decode.ParseBytes32(args[2]) + arg__treasury, err := chainutil.AddressFromHex(args[2]) if err != nil { return fmt.Errorf( - "couldn't parse parameter arg_publicKeyY, a bytes32, from passed value %v", + "couldn't parse parameter arg__treasury, a address, from passed value %v", args[2], ) } + arg__ecdsaWalletRegistry, err := chainutil.AddressFromHex(args[3]) + if err != nil { + return fmt.Errorf( + "couldn't parse parameter arg__ecdsaWalletRegistry, a address, from passed value %v", + args[3], + ) + } + arg__reimbursementPool, err := chainutil.AddressFromHex(args[4]) + if err != nil { + return fmt.Errorf( + "couldn't parse parameter arg__reimbursementPool, a address, from passed value %v", + args[4], + ) + } + arg__txProofDifficultyFactor, err := hexutil.DecodeBig(args[5]) + if err != nil { + return fmt.Errorf( + "couldn't parse parameter arg__txProofDifficultyFactor, a uint96, from passed value %v", + args[5], + ) + } var ( transaction *types.Transaction @@ -1274,10 +1395,13 @@ func bEcdsaWalletCreatedCallback(c *cobra.Command, args []string) error { if shouldSubmit, _ := c.Flags().GetBool(cmd.SubmitFlag); shouldSubmit { // Do a regular submission. Take payable into account. - transaction, err = contract.EcdsaWalletCreatedCallback( - arg_ecdsaWalletID, - arg_publicKeyX, - arg_publicKeyY, + transaction, err = contract.Initialize( + arg__bank, + arg__relay, + arg__treasury, + arg__ecdsaWalletRegistry, + arg__reimbursementPool, + arg__txProofDifficultyFactor, ) if err != nil { return err @@ -1286,10 +1410,13 @@ func bEcdsaWalletCreatedCallback(c *cobra.Command, args []string) error { cmd.PrintOutput(transaction.Hash()) } else { // Do a call. - err = contract.CallEcdsaWalletCreatedCallback( - arg_ecdsaWalletID, - arg_publicKeyX, - arg_publicKeyY, + err = contract.CallInitialize( + arg__bank, + arg__relay, + arg__treasury, + arg__ecdsaWalletRegistry, + arg__reimbursementPool, + arg__txProofDifficultyFactor, cmd.BlockFlagValue.Int, ) if err != nil { @@ -1307,12 +1434,12 @@ func bEcdsaWalletCreatedCallback(c *cobra.Command, args []string) error { return nil } -func bEcdsaWalletHeartbeatFailedCallbackCommand() *cobra.Command { +func bInitializeV2FixVaultZeroDepositCommand() *cobra.Command { c := &cobra.Command{ - Use: "ecdsa-wallet-heartbeat-failed-callback [arg0] [arg_publicKeyX] [arg_publicKeyY]", - Short: "Calls the nonpayable method ecdsaWalletHeartbeatFailedCallback on the Bridge contract.", - Args: cmd.ArgCountChecker(3), - RunE: bEcdsaWalletHeartbeatFailedCallback, + Use: "initialize-v2-fix-vault-zero-deposit", + Short: "Calls the nonpayable method initializeV2FixVaultZeroDeposit on the Bridge contract.", + Args: cmd.ArgCountChecker(0), + RunE: bInitializeV2FixVaultZeroDeposit, SilenceUsage: true, DisableFlagsInUseLine: true, } @@ -1323,45 +1450,19 @@ func bEcdsaWalletHeartbeatFailedCallbackCommand() *cobra.Command { return c } -func bEcdsaWalletHeartbeatFailedCallback(c *cobra.Command, args []string) error { +func bInitializeV2FixVaultZeroDeposit(c *cobra.Command, args []string) error { contract, err := initializeBridge(c) if err != nil { return err } - arg0, err := decode.ParseBytes32(args[0]) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter arg0, a bytes32, from passed value %v", - args[0], - ) - } - arg_publicKeyX, err := decode.ParseBytes32(args[1]) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter arg_publicKeyX, a bytes32, from passed value %v", - args[1], - ) - } - arg_publicKeyY, err := decode.ParseBytes32(args[2]) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter arg_publicKeyY, a bytes32, from passed value %v", - args[2], - ) - } - var ( transaction *types.Transaction ) if shouldSubmit, _ := c.Flags().GetBool(cmd.SubmitFlag); shouldSubmit { // Do a regular submission. Take payable into account. - transaction, err = contract.EcdsaWalletHeartbeatFailedCallback( - arg0, - arg_publicKeyX, - arg_publicKeyY, - ) + transaction, err = contract.InitializeV2FixVaultZeroDeposit() if err != nil { return err } @@ -1369,10 +1470,7 @@ func bEcdsaWalletHeartbeatFailedCallback(c *cobra.Command, args []string) error cmd.PrintOutput(transaction.Hash()) } else { // Do a call. - err = contract.CallEcdsaWalletHeartbeatFailedCallback( - arg0, - arg_publicKeyX, - arg_publicKeyY, + err = contract.CallInitializeV2FixVaultZeroDeposit( cmd.BlockFlagValue.Int, ) if err != nil { @@ -1390,12 +1488,12 @@ func bEcdsaWalletHeartbeatFailedCallback(c *cobra.Command, args []string) error return nil } -func bInitializeCommand() *cobra.Command { +func bNotifyMovingFundsBelowDustCommand() *cobra.Command { c := &cobra.Command{ - Use: "initialize [arg__bank] [arg__relay] [arg__treasury] [arg__ecdsaWalletRegistry] [arg__reimbursementPool] [arg__txProofDifficultyFactor]", - Short: "Calls the nonpayable method initialize on the Bridge contract.", - Args: cmd.ArgCountChecker(6), - RunE: bInitialize, + Use: "notify-moving-funds-below-dust [arg_walletPubKeyHash] [arg_mainUtxo_json]", + Short: "Calls the nonpayable method notifyMovingFundsBelowDust on the Bridge contract.", + Args: cmd.ArgCountChecker(2), + RunE: bNotifyMovingFundsBelowDust, SilenceUsage: true, DisableFlagsInUseLine: true, } @@ -1406,187 +1504,23 @@ func bInitializeCommand() *cobra.Command { return c } -func bInitialize(c *cobra.Command, args []string) error { +func bNotifyMovingFundsBelowDust(c *cobra.Command, args []string) error { contract, err := initializeBridge(c) if err != nil { return err } - arg__bank, err := chainutil.AddressFromHex(args[0]) + arg_walletPubKeyHash, err := decode.ParseBytes20(args[0]) if err != nil { return fmt.Errorf( - "couldn't parse parameter arg__bank, a address, from passed value %v", + "couldn't parse parameter arg_walletPubKeyHash, a bytes20, from passed value %v", args[0], ) } - arg__relay, err := chainutil.AddressFromHex(args[1]) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter arg__relay, a address, from passed value %v", - args[1], - ) - } - arg__treasury, err := chainutil.AddressFromHex(args[2]) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter arg__treasury, a address, from passed value %v", - args[2], - ) - } - arg__ecdsaWalletRegistry, err := chainutil.AddressFromHex(args[3]) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter arg__ecdsaWalletRegistry, a address, from passed value %v", - args[3], - ) - } - arg__reimbursementPool, err := chainutil.AddressFromHex(args[4]) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter arg__reimbursementPool, a address, from passed value %v", - args[4], - ) - } - arg__txProofDifficultyFactor, err := hexutil.DecodeBig(args[5]) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter arg__txProofDifficultyFactor, a uint96, from passed value %v", - args[5], - ) - } - - var ( - transaction *types.Transaction - ) - - if shouldSubmit, _ := c.Flags().GetBool(cmd.SubmitFlag); shouldSubmit { - // Do a regular submission. Take payable into account. - transaction, err = contract.Initialize( - arg__bank, - arg__relay, - arg__treasury, - arg__ecdsaWalletRegistry, - arg__reimbursementPool, - arg__txProofDifficultyFactor, - ) - if err != nil { - return err - } - - cmd.PrintOutput(transaction.Hash()) - } else { - // Do a call. - err = contract.CallInitialize( - arg__bank, - arg__relay, - arg__treasury, - arg__ecdsaWalletRegistry, - arg__reimbursementPool, - arg__txProofDifficultyFactor, - cmd.BlockFlagValue.Int, - ) - if err != nil { - return err - } - - cmd.PrintOutput("success") - - cmd.PrintOutput( - "the transaction was not submitted to the chain; " + - "please add the `--submit` flag", - ) - } - - return nil -} - -func bInitializeV2FixVaultZeroDepositCommand() *cobra.Command { - c := &cobra.Command{ - Use: "initialize-v2-fix-vault-zero-deposit", - Short: "Calls the nonpayable method initializeV2FixVaultZeroDeposit on the Bridge contract.", - Args: cmd.ArgCountChecker(0), - RunE: bInitializeV2FixVaultZeroDeposit, - SilenceUsage: true, - DisableFlagsInUseLine: true, - } - - c.PreRunE = cmd.NonConstArgsChecker - cmd.InitNonConstFlags(c) - - return c -} - -func bInitializeV2FixVaultZeroDeposit(c *cobra.Command, args []string) error { - contract, err := initializeBridge(c) - if err != nil { - return err - } - - var ( - transaction *types.Transaction - ) - - if shouldSubmit, _ := c.Flags().GetBool(cmd.SubmitFlag); shouldSubmit { - // Do a regular submission. Take payable into account. - transaction, err = contract.InitializeV2FixVaultZeroDeposit() - if err != nil { - return err - } - - cmd.PrintOutput(transaction.Hash()) - } else { - // Do a call. - err = contract.CallInitializeV2FixVaultZeroDeposit( - cmd.BlockFlagValue.Int, - ) - if err != nil { - return err - } - - cmd.PrintOutput("success") - - cmd.PrintOutput( - "the transaction was not submitted to the chain; " + - "please add the `--submit` flag", - ) - } - - return nil -} - -func bNotifyMovingFundsBelowDustCommand() *cobra.Command { - c := &cobra.Command{ - Use: "notify-moving-funds-below-dust [arg_walletPubKeyHash] [arg_mainUtxo_json]", - Short: "Calls the nonpayable method notifyMovingFundsBelowDust on the Bridge contract.", - Args: cmd.ArgCountChecker(2), - RunE: bNotifyMovingFundsBelowDust, - SilenceUsage: true, - DisableFlagsInUseLine: true, - } - - c.PreRunE = cmd.NonConstArgsChecker - cmd.InitNonConstFlags(c) - - return c -} - -func bNotifyMovingFundsBelowDust(c *cobra.Command, args []string) error { - contract, err := initializeBridge(c) - if err != nil { - return err - } - - arg_walletPubKeyHash, err := decode.ParseBytes20(args[0]) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter arg_walletPubKeyHash, a bytes20, from passed value %v", - args[0], - ) - } - - arg_mainUtxo_json := abi.BitcoinTxUTXO{} - if err := json.Unmarshal([]byte(args[1]), &arg_mainUtxo_json); err != nil { - return fmt.Errorf("failed to unmarshal arg_mainUtxo_json to abi.BitcoinTxUTXO: %w", err) + + arg_mainUtxo_json := abi.BitcoinTxUTXO{} + if err := json.Unmarshal([]byte(args[1]), &arg_mainUtxo_json); err != nil { + return fmt.Errorf("failed to unmarshal arg_mainUtxo_json to abi.BitcoinTxUTXO: %w", err) } var ( @@ -2137,6 +2071,60 @@ func bResetMovingFundsTimeout(c *cobra.Command, args []string) error { return nil } +func bRetireEcdsaCommand() *cobra.Command { + c := &cobra.Command{ + Use: "retire-ecdsa", + Short: "Calls the nonpayable method retireEcdsa on the Bridge contract.", + Args: cmd.ArgCountChecker(0), + RunE: bRetireEcdsa, + SilenceUsage: true, + DisableFlagsInUseLine: true, + } + + c.PreRunE = cmd.NonConstArgsChecker + cmd.InitNonConstFlags(c) + + return c +} + +func bRetireEcdsa(c *cobra.Command, args []string) error { + contract, err := initializeBridge(c) + if err != nil { + return err + } + + var ( + transaction *types.Transaction + ) + + if shouldSubmit, _ := c.Flags().GetBool(cmd.SubmitFlag); shouldSubmit { + // Do a regular submission. Take payable into account. + transaction, err = contract.RetireEcdsa() + if err != nil { + return err + } + + cmd.PrintOutput(transaction.Hash()) + } else { + // Do a call. + err = contract.CallRetireEcdsa( + cmd.BlockFlagValue.Int, + ) + if err != nil { + return err + } + + cmd.PrintOutput("success") + + cmd.PrintOutput( + "the transaction was not submitted to the chain; " + + "please add the `--submit` flag", + ) + } + + return nil +} + func bRevealDepositCommand() *cobra.Command { c := &cobra.Command{ Use: "reveal-deposit [arg_fundingTx_json] [arg_reveal_json]", @@ -2284,12 +2272,12 @@ func bRevealDepositWithExtraData(c *cobra.Command, args []string) error { return nil } -func bSetRebateStakingCommand() *cobra.Command { +func bRevealTaprootDepositCommand() *cobra.Command { c := &cobra.Command{ - Use: "set-rebate-staking [arg_rebateStaking]", - Short: "Calls the nonpayable method setRebateStaking on the Bridge contract.", - Args: cmd.ArgCountChecker(1), - RunE: bSetRebateStaking, + Use: "reveal-taproot-deposit [arg_fundingTx_json] [arg_reveal_json]", + Short: "Calls the nonpayable method revealTaprootDeposit on the Bridge contract.", + Args: cmd.ArgCountChecker(2), + RunE: bRevealTaprootDeposit, SilenceUsage: true, DisableFlagsInUseLine: true, } @@ -2300,18 +2288,20 @@ func bSetRebateStakingCommand() *cobra.Command { return c } -func bSetRebateStaking(c *cobra.Command, args []string) error { +func bRevealTaprootDeposit(c *cobra.Command, args []string) error { contract, err := initializeBridge(c) if err != nil { return err } - arg_rebateStaking, err := chainutil.AddressFromHex(args[0]) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter arg_rebateStaking, a address, from passed value %v", - args[0], - ) + arg_fundingTx_json := abi.BitcoinTxInfo{} + if err := json.Unmarshal([]byte(args[0]), &arg_fundingTx_json); err != nil { + return fmt.Errorf("failed to unmarshal arg_fundingTx_json to abi.BitcoinTxInfo: %w", err) + } + + arg_reveal_json := abi.DepositTaprootDepositRevealInfo{} + if err := json.Unmarshal([]byte(args[1]), &arg_reveal_json); err != nil { + return fmt.Errorf("failed to unmarshal arg_reveal_json to abi.DepositTaprootDepositRevealInfo: %w", err) } var ( @@ -2320,8 +2310,9 @@ func bSetRebateStaking(c *cobra.Command, args []string) error { if shouldSubmit, _ := c.Flags().GetBool(cmd.SubmitFlag); shouldSubmit { // Do a regular submission. Take payable into account. - transaction, err = contract.SetRebateStaking( - arg_rebateStaking, + transaction, err = contract.RevealTaprootDeposit( + arg_fundingTx_json, + arg_reveal_json, ) if err != nil { return err @@ -2330,8 +2321,9 @@ func bSetRebateStaking(c *cobra.Command, args []string) error { cmd.PrintOutput(transaction.Hash()) } else { // Do a call. - err = contract.CallSetRebateStaking( - arg_rebateStaking, + err = contract.CallRevealTaprootDeposit( + arg_fundingTx_json, + arg_reveal_json, cmd.BlockFlagValue.Int, ) if err != nil { @@ -2349,12 +2341,12 @@ func bSetRebateStaking(c *cobra.Command, args []string) error { return nil } -func bSetRedemptionWatchtowerCommand() *cobra.Command { +func bRevealTaprootDepositWithExtraDataCommand() *cobra.Command { c := &cobra.Command{ - Use: "set-redemption-watchtower [arg_redemptionWatchtower]", - Short: "Calls the nonpayable method setRedemptionWatchtower on the Bridge contract.", - Args: cmd.ArgCountChecker(1), - RunE: bSetRedemptionWatchtower, + Use: "reveal-taproot-deposit-with-extra-data [arg_fundingTx_json] [arg_reveal_json] [arg_extraData]", + Short: "Calls the nonpayable method revealTaprootDepositWithExtraData on the Bridge contract.", + Args: cmd.ArgCountChecker(3), + RunE: bRevealTaprootDepositWithExtraData, SilenceUsage: true, DisableFlagsInUseLine: true, } @@ -2365,17 +2357,26 @@ func bSetRedemptionWatchtowerCommand() *cobra.Command { return c } -func bSetRedemptionWatchtower(c *cobra.Command, args []string) error { +func bRevealTaprootDepositWithExtraData(c *cobra.Command, args []string) error { contract, err := initializeBridge(c) if err != nil { return err } - arg_redemptionWatchtower, err := chainutil.AddressFromHex(args[0]) + arg_fundingTx_json := abi.BitcoinTxInfo{} + if err := json.Unmarshal([]byte(args[0]), &arg_fundingTx_json); err != nil { + return fmt.Errorf("failed to unmarshal arg_fundingTx_json to abi.BitcoinTxInfo: %w", err) + } + + arg_reveal_json := abi.DepositTaprootDepositRevealInfo{} + if err := json.Unmarshal([]byte(args[1]), &arg_reveal_json); err != nil { + return fmt.Errorf("failed to unmarshal arg_reveal_json to abi.DepositTaprootDepositRevealInfo: %w", err) + } + arg_extraData, err := decode.ParseBytes32(args[2]) if err != nil { return fmt.Errorf( - "couldn't parse parameter arg_redemptionWatchtower, a address, from passed value %v", - args[0], + "couldn't parse parameter arg_extraData, a bytes32, from passed value %v", + args[2], ) } @@ -2385,8 +2386,10 @@ func bSetRedemptionWatchtower(c *cobra.Command, args []string) error { if shouldSubmit, _ := c.Flags().GetBool(cmd.SubmitFlag); shouldSubmit { // Do a regular submission. Take payable into account. - transaction, err = contract.SetRedemptionWatchtower( - arg_redemptionWatchtower, + transaction, err = contract.RevealTaprootDepositWithExtraData( + arg_fundingTx_json, + arg_reveal_json, + arg_extraData, ) if err != nil { return err @@ -2395,9 +2398,401 @@ func bSetRedemptionWatchtower(c *cobra.Command, args []string) error { cmd.PrintOutput(transaction.Hash()) } else { // Do a call. - err = contract.CallSetRedemptionWatchtower( - arg_redemptionWatchtower, - cmd.BlockFlagValue.Int, + err = contract.CallRevealTaprootDepositWithExtraData( + arg_fundingTx_json, + arg_reveal_json, + arg_extraData, + cmd.BlockFlagValue.Int, + ) + if err != nil { + return err + } + + cmd.PrintOutput("success") + + cmd.PrintOutput( + "the transaction was not submitted to the chain; " + + "please add the `--submit` flag", + ) + } + + return nil +} + +func bSetEcdsaFraudRouterCommand() *cobra.Command { + c := &cobra.Command{ + Use: "set-ecdsa-fraud-router [arg_ecdsaFraudRouter]", + Short: "Calls the nonpayable method setEcdsaFraudRouter on the Bridge contract.", + Args: cmd.ArgCountChecker(1), + RunE: bSetEcdsaFraudRouter, + SilenceUsage: true, + DisableFlagsInUseLine: true, + } + + c.PreRunE = cmd.NonConstArgsChecker + cmd.InitNonConstFlags(c) + + return c +} + +func bSetEcdsaFraudRouter(c *cobra.Command, args []string) error { + contract, err := initializeBridge(c) + if err != nil { + return err + } + + arg_ecdsaFraudRouter, err := chainutil.AddressFromHex(args[0]) + if err != nil { + return fmt.Errorf( + "couldn't parse parameter arg_ecdsaFraudRouter, a address, from passed value %v", + args[0], + ) + } + + var ( + transaction *types.Transaction + ) + + if shouldSubmit, _ := c.Flags().GetBool(cmd.SubmitFlag); shouldSubmit { + // Do a regular submission. Take payable into account. + transaction, err = contract.SetEcdsaFraudRouter( + arg_ecdsaFraudRouter, + ) + if err != nil { + return err + } + + cmd.PrintOutput(transaction.Hash()) + } else { + // Do a call. + err = contract.CallSetEcdsaFraudRouter( + arg_ecdsaFraudRouter, + cmd.BlockFlagValue.Int, + ) + if err != nil { + return err + } + + cmd.PrintOutput("success") + + cmd.PrintOutput( + "the transaction was not submitted to the chain; " + + "please add the `--submit` flag", + ) + } + + return nil +} + +func bSetFrostWalletRegistryCommand() *cobra.Command { + c := &cobra.Command{ + Use: "set-frost-wallet-registry [arg_frostWalletRegistry]", + Short: "Calls the nonpayable method setFrostWalletRegistry on the Bridge contract.", + Args: cmd.ArgCountChecker(1), + RunE: bSetFrostWalletRegistry, + SilenceUsage: true, + DisableFlagsInUseLine: true, + } + + c.PreRunE = cmd.NonConstArgsChecker + cmd.InitNonConstFlags(c) + + return c +} + +func bSetFrostWalletRegistry(c *cobra.Command, args []string) error { + contract, err := initializeBridge(c) + if err != nil { + return err + } + + arg_frostWalletRegistry, err := chainutil.AddressFromHex(args[0]) + if err != nil { + return fmt.Errorf( + "couldn't parse parameter arg_frostWalletRegistry, a address, from passed value %v", + args[0], + ) + } + + var ( + transaction *types.Transaction + ) + + if shouldSubmit, _ := c.Flags().GetBool(cmd.SubmitFlag); shouldSubmit { + // Do a regular submission. Take payable into account. + transaction, err = contract.SetFrostWalletRegistry( + arg_frostWalletRegistry, + ) + if err != nil { + return err + } + + cmd.PrintOutput(transaction.Hash()) + } else { + // Do a call. + err = contract.CallSetFrostWalletRegistry( + arg_frostWalletRegistry, + cmd.BlockFlagValue.Int, + ) + if err != nil { + return err + } + + cmd.PrintOutput("success") + + cmd.PrintOutput( + "the transaction was not submitted to the chain; " + + "please add the `--submit` flag", + ) + } + + return nil +} + +func bSetLifecycleRouterCommand() *cobra.Command { + c := &cobra.Command{ + Use: "set-lifecycle-router [arg_lifecycleRouter]", + Short: "Calls the nonpayable method setLifecycleRouter on the Bridge contract.", + Args: cmd.ArgCountChecker(1), + RunE: bSetLifecycleRouter, + SilenceUsage: true, + DisableFlagsInUseLine: true, + } + + c.PreRunE = cmd.NonConstArgsChecker + cmd.InitNonConstFlags(c) + + return c +} + +func bSetLifecycleRouter(c *cobra.Command, args []string) error { + contract, err := initializeBridge(c) + if err != nil { + return err + } + + arg_lifecycleRouter, err := chainutil.AddressFromHex(args[0]) + if err != nil { + return fmt.Errorf( + "couldn't parse parameter arg_lifecycleRouter, a address, from passed value %v", + args[0], + ) + } + + var ( + transaction *types.Transaction + ) + + if shouldSubmit, _ := c.Flags().GetBool(cmd.SubmitFlag); shouldSubmit { + // Do a regular submission. Take payable into account. + transaction, err = contract.SetLifecycleRouter( + arg_lifecycleRouter, + ) + if err != nil { + return err + } + + cmd.PrintOutput(transaction.Hash()) + } else { + // Do a call. + err = contract.CallSetLifecycleRouter( + arg_lifecycleRouter, + cmd.BlockFlagValue.Int, + ) + if err != nil { + return err + } + + cmd.PrintOutput("success") + + cmd.PrintOutput( + "the transaction was not submitted to the chain; " + + "please add the `--submit` flag", + ) + } + + return nil +} + +func bSetP2TRFraudRouterCommand() *cobra.Command { + c := &cobra.Command{ + Use: "set-p2-t-r-fraud-router [arg_p2trFraudRouter]", + Short: "Calls the nonpayable method setP2TRFraudRouter on the Bridge contract.", + Args: cmd.ArgCountChecker(1), + RunE: bSetP2TRFraudRouter, + SilenceUsage: true, + DisableFlagsInUseLine: true, + } + + c.PreRunE = cmd.NonConstArgsChecker + cmd.InitNonConstFlags(c) + + return c +} + +func bSetP2TRFraudRouter(c *cobra.Command, args []string) error { + contract, err := initializeBridge(c) + if err != nil { + return err + } + + arg_p2trFraudRouter, err := chainutil.AddressFromHex(args[0]) + if err != nil { + return fmt.Errorf( + "couldn't parse parameter arg_p2trFraudRouter, a address, from passed value %v", + args[0], + ) + } + + var ( + transaction *types.Transaction + ) + + if shouldSubmit, _ := c.Flags().GetBool(cmd.SubmitFlag); shouldSubmit { + // Do a regular submission. Take payable into account. + transaction, err = contract.SetP2TRFraudRouter( + arg_p2trFraudRouter, + ) + if err != nil { + return err + } + + cmd.PrintOutput(transaction.Hash()) + } else { + // Do a call. + err = contract.CallSetP2TRFraudRouter( + arg_p2trFraudRouter, + cmd.BlockFlagValue.Int, + ) + if err != nil { + return err + } + + cmd.PrintOutput("success") + + cmd.PrintOutput( + "the transaction was not submitted to the chain; " + + "please add the `--submit` flag", + ) + } + + return nil +} + +func bSetRebateStakingCommand() *cobra.Command { + c := &cobra.Command{ + Use: "set-rebate-staking [arg_rebateStaking]", + Short: "Calls the nonpayable method setRebateStaking on the Bridge contract.", + Args: cmd.ArgCountChecker(1), + RunE: bSetRebateStaking, + SilenceUsage: true, + DisableFlagsInUseLine: true, + } + + c.PreRunE = cmd.NonConstArgsChecker + cmd.InitNonConstFlags(c) + + return c +} + +func bSetRebateStaking(c *cobra.Command, args []string) error { + contract, err := initializeBridge(c) + if err != nil { + return err + } + + arg_rebateStaking, err := chainutil.AddressFromHex(args[0]) + if err != nil { + return fmt.Errorf( + "couldn't parse parameter arg_rebateStaking, a address, from passed value %v", + args[0], + ) + } + + var ( + transaction *types.Transaction + ) + + if shouldSubmit, _ := c.Flags().GetBool(cmd.SubmitFlag); shouldSubmit { + // Do a regular submission. Take payable into account. + transaction, err = contract.SetRebateStaking( + arg_rebateStaking, + ) + if err != nil { + return err + } + + cmd.PrintOutput(transaction.Hash()) + } else { + // Do a call. + err = contract.CallSetRebateStaking( + arg_rebateStaking, + cmd.BlockFlagValue.Int, + ) + if err != nil { + return err + } + + cmd.PrintOutput("success") + + cmd.PrintOutput( + "the transaction was not submitted to the chain; " + + "please add the `--submit` flag", + ) + } + + return nil +} + +func bSetRedemptionWatchtowerCommand() *cobra.Command { + c := &cobra.Command{ + Use: "set-redemption-watchtower [arg_redemptionWatchtower]", + Short: "Calls the nonpayable method setRedemptionWatchtower on the Bridge contract.", + Args: cmd.ArgCountChecker(1), + RunE: bSetRedemptionWatchtower, + SilenceUsage: true, + DisableFlagsInUseLine: true, + } + + c.PreRunE = cmd.NonConstArgsChecker + cmd.InitNonConstFlags(c) + + return c +} + +func bSetRedemptionWatchtower(c *cobra.Command, args []string) error { + contract, err := initializeBridge(c) + if err != nil { + return err + } + + arg_redemptionWatchtower, err := chainutil.AddressFromHex(args[0]) + if err != nil { + return fmt.Errorf( + "couldn't parse parameter arg_redemptionWatchtower, a address, from passed value %v", + args[0], + ) + } + + var ( + transaction *types.Transaction + ) + + if shouldSubmit, _ := c.Flags().GetBool(cmd.SubmitFlag); shouldSubmit { + // Do a regular submission. Take payable into account. + transaction, err = contract.SetRedemptionWatchtower( + arg_redemptionWatchtower, + ) + if err != nil { + return err + } + + cmd.PrintOutput(transaction.Hash()) + } else { + // Do a call. + err = contract.CallSetRedemptionWatchtower( + arg_redemptionWatchtower, + cmd.BlockFlagValue.Int, ) if err != nil { return err @@ -2647,87 +3042,6 @@ func bSubmitDepositSweepProof(c *cobra.Command, args []string) error { return nil } -func bSubmitFraudChallengeCommand() *cobra.Command { - c := &cobra.Command{ - Use: "submit-fraud-challenge [arg_walletPublicKey] [arg_preimageSha256] [arg_signature_json]", - Short: "Calls the payable method submitFraudChallenge on the Bridge contract.", - Args: cmd.ArgCountChecker(3), - RunE: bSubmitFraudChallenge, - SilenceUsage: true, - DisableFlagsInUseLine: true, - } - - c.PreRunE = cmd.NonConstArgsChecker - cmd.InitNonConstFlags(c) - - return c -} - -func bSubmitFraudChallenge(c *cobra.Command, args []string) error { - contract, err := initializeBridge(c) - if err != nil { - return err - } - - arg_walletPublicKey, err := hexutil.Decode(args[0]) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter arg_walletPublicKey, a bytes, from passed value %v", - args[0], - ) - } - arg_preimageSha256, err := hexutil.Decode(args[1]) - if err != nil { - return fmt.Errorf( - "couldn't parse parameter arg_preimageSha256, a bytes, from passed value %v", - args[1], - ) - } - - arg_signature_json := abi.BitcoinTxRSVSignature{} - if err := json.Unmarshal([]byte(args[2]), &arg_signature_json); err != nil { - return fmt.Errorf("failed to unmarshal arg_signature_json to abi.BitcoinTxRSVSignature: %w", err) - } - - var ( - transaction *types.Transaction - ) - - if shouldSubmit, _ := c.Flags().GetBool(cmd.SubmitFlag); shouldSubmit { - // Do a regular submission. Take payable into account. - transaction, err = contract.SubmitFraudChallenge( - arg_walletPublicKey, - arg_preimageSha256, - arg_signature_json, - ) - if err != nil { - return err - } - - cmd.PrintOutput(transaction.Hash()) - } else { - // Do a call. - err = contract.CallSubmitFraudChallenge( - arg_walletPublicKey, - arg_preimageSha256, - arg_signature_json, - cmd.BlockFlagValue.Int, - ) - if err != nil { - return err - } - - cmd.PrintOutput("success") - - cmd.PrintOutput( - "the transaction was not submitted to the chain; " + - "please add the `--submit` flag", - ) - } - - return nil -} - func bSubmitMovedFundsSweepProofCommand() *cobra.Command { c := &cobra.Command{ Use: "submit-moved-funds-sweep-proof [arg_sweepTx_json] [arg_sweepProof_json] [arg_mainUtxo_json]", diff --git a/pkg/chain/ethereum/tbtc/gen/contract/Bridge.go b/pkg/chain/ethereum/tbtc/gen/contract/Bridge.go index c0b3348064..58d179f812 100644 --- a/pkg/chain/ethereum/tbtc/gen/contract/Bridge.go +++ b/pkg/chain/ethereum/tbtc/gen/contract/Bridge.go @@ -105,20 +105,20 @@ func NewBridge( // ----- Non-const Methods ------ // Transaction submission. -func (b *Bridge) DefeatFraudChallenge( - arg_walletPublicKey []byte, - arg_preimage []byte, - arg_witness bool, +func (b *Bridge) EcdsaWalletHeartbeatFailedCallback( + arg0 [32]byte, + arg_publicKeyX [32]byte, + arg_publicKeyY [32]byte, transactionOptions ...chainutil.TransactionOptions, ) (*types.Transaction, error) { bLogger.Debug( - "submitting transaction defeatFraudChallenge", + "submitting transaction ecdsaWalletHeartbeatFailedCallback", " params: ", fmt.Sprint( - arg_walletPublicKey, - arg_preimage, - arg_witness, + arg0, + arg_publicKeyX, + arg_publicKeyY, ), ) @@ -144,26 +144,26 @@ func (b *Bridge) DefeatFraudChallenge( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := b.contract.DefeatFraudChallenge( + transaction, err := b.contract.EcdsaWalletHeartbeatFailedCallback( transactorOptions, - arg_walletPublicKey, - arg_preimage, - arg_witness, + arg0, + arg_publicKeyX, + arg_publicKeyY, ) if err != nil { return transaction, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "defeatFraudChallenge", - arg_walletPublicKey, - arg_preimage, - arg_witness, + "ecdsaWalletHeartbeatFailedCallback", + arg0, + arg_publicKeyX, + arg_publicKeyY, ) } bLogger.Infof( - "submitted transaction defeatFraudChallenge with id: [%s] and nonce [%v]", + "submitted transaction ecdsaWalletHeartbeatFailedCallback with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -182,26 +182,26 @@ func (b *Bridge) DefeatFraudChallenge( newTransactorOptions.GasLimit = transactorOptions.GasLimit } - transaction, err := b.contract.DefeatFraudChallenge( + transaction, err := b.contract.EcdsaWalletHeartbeatFailedCallback( newTransactorOptions, - arg_walletPublicKey, - arg_preimage, - arg_witness, + arg0, + arg_publicKeyX, + arg_publicKeyY, ) if err != nil { return nil, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "defeatFraudChallenge", - arg_walletPublicKey, - arg_preimage, - arg_witness, + "ecdsaWalletHeartbeatFailedCallback", + arg0, + arg_publicKeyX, + arg_publicKeyY, ) } bLogger.Infof( - "submitted transaction defeatFraudChallenge with id: [%s] and nonce [%v]", + "submitted transaction ecdsaWalletHeartbeatFailedCallback with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -216,10 +216,10 @@ func (b *Bridge) DefeatFraudChallenge( } // Non-mutating call, not a transaction submission. -func (b *Bridge) CallDefeatFraudChallenge( - arg_walletPublicKey []byte, - arg_preimage []byte, - arg_witness bool, +func (b *Bridge) CallEcdsaWalletHeartbeatFailedCallback( + arg0 [32]byte, + arg_publicKeyX [32]byte, + arg_publicKeyY [32]byte, blockNumber *big.Int, ) error { var result interface{} = nil @@ -231,50 +231,48 @@ func (b *Bridge) CallDefeatFraudChallenge( b.caller, b.errorResolver, b.contractAddress, - "defeatFraudChallenge", + "ecdsaWalletHeartbeatFailedCallback", &result, - arg_walletPublicKey, - arg_preimage, - arg_witness, + arg0, + arg_publicKeyX, + arg_publicKeyY, ) return err } -func (b *Bridge) DefeatFraudChallengeGasEstimate( - arg_walletPublicKey []byte, - arg_preimage []byte, - arg_witness bool, +func (b *Bridge) EcdsaWalletHeartbeatFailedCallbackGasEstimate( + arg0 [32]byte, + arg_publicKeyX [32]byte, + arg_publicKeyY [32]byte, ) (uint64, error) { var result uint64 result, err := chainutil.EstimateGas( b.callerOptions.From, b.contractAddress, - "defeatFraudChallenge", + "ecdsaWalletHeartbeatFailedCallback", b.contractABI, b.transactor, - arg_walletPublicKey, - arg_preimage, - arg_witness, + arg0, + arg_publicKeyX, + arg_publicKeyY, ) return result, err } // Transaction submission. -func (b *Bridge) DefeatFraudChallengeWithHeartbeat( - arg_walletPublicKey []byte, - arg_heartbeatMessage []byte, +func (b *Bridge) FrostWalletCreatedCallback( + arg_xOnlyOutputKey [32]byte, transactionOptions ...chainutil.TransactionOptions, ) (*types.Transaction, error) { bLogger.Debug( - "submitting transaction defeatFraudChallengeWithHeartbeat", + "submitting transaction frostWalletCreatedCallback", " params: ", fmt.Sprint( - arg_walletPublicKey, - arg_heartbeatMessage, + arg_xOnlyOutputKey, ), ) @@ -300,24 +298,22 @@ func (b *Bridge) DefeatFraudChallengeWithHeartbeat( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := b.contract.DefeatFraudChallengeWithHeartbeat( + transaction, err := b.contract.FrostWalletCreatedCallback( transactorOptions, - arg_walletPublicKey, - arg_heartbeatMessage, + arg_xOnlyOutputKey, ) if err != nil { return transaction, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "defeatFraudChallengeWithHeartbeat", - arg_walletPublicKey, - arg_heartbeatMessage, + "frostWalletCreatedCallback", + arg_xOnlyOutputKey, ) } bLogger.Infof( - "submitted transaction defeatFraudChallengeWithHeartbeat with id: [%s] and nonce [%v]", + "submitted transaction frostWalletCreatedCallback with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -336,24 +332,22 @@ func (b *Bridge) DefeatFraudChallengeWithHeartbeat( newTransactorOptions.GasLimit = transactorOptions.GasLimit } - transaction, err := b.contract.DefeatFraudChallengeWithHeartbeat( + transaction, err := b.contract.FrostWalletCreatedCallback( newTransactorOptions, - arg_walletPublicKey, - arg_heartbeatMessage, + arg_xOnlyOutputKey, ) if err != nil { return nil, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "defeatFraudChallengeWithHeartbeat", - arg_walletPublicKey, - arg_heartbeatMessage, + "frostWalletCreatedCallback", + arg_xOnlyOutputKey, ) } bLogger.Infof( - "submitted transaction defeatFraudChallengeWithHeartbeat with id: [%s] and nonce [%v]", + "submitted transaction frostWalletCreatedCallback with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -368,9 +362,8 @@ func (b *Bridge) DefeatFraudChallengeWithHeartbeat( } // Non-mutating call, not a transaction submission. -func (b *Bridge) CallDefeatFraudChallengeWithHeartbeat( - arg_walletPublicKey []byte, - arg_heartbeatMessage []byte, +func (b *Bridge) CallFrostWalletCreatedCallback( + arg_xOnlyOutputKey [32]byte, blockNumber *big.Int, ) error { var result interface{} = nil @@ -382,49 +375,52 @@ func (b *Bridge) CallDefeatFraudChallengeWithHeartbeat( b.caller, b.errorResolver, b.contractAddress, - "defeatFraudChallengeWithHeartbeat", + "frostWalletCreatedCallback", &result, - arg_walletPublicKey, - arg_heartbeatMessage, + arg_xOnlyOutputKey, ) return err } -func (b *Bridge) DefeatFraudChallengeWithHeartbeatGasEstimate( - arg_walletPublicKey []byte, - arg_heartbeatMessage []byte, +func (b *Bridge) FrostWalletCreatedCallbackGasEstimate( + arg_xOnlyOutputKey [32]byte, ) (uint64, error) { var result uint64 result, err := chainutil.EstimateGas( b.callerOptions.From, b.contractAddress, - "defeatFraudChallengeWithHeartbeat", + "frostWalletCreatedCallback", b.contractABI, b.transactor, - arg_walletPublicKey, - arg_heartbeatMessage, + arg_xOnlyOutputKey, ) return result, err } // Transaction submission. -func (b *Bridge) EcdsaWalletCreatedCallback( - arg_ecdsaWalletID [32]byte, - arg_publicKeyX [32]byte, - arg_publicKeyY [32]byte, +func (b *Bridge) Initialize( + arg__bank common.Address, + arg__relay common.Address, + arg__treasury common.Address, + arg__ecdsaWalletRegistry common.Address, + arg__reimbursementPool common.Address, + arg__txProofDifficultyFactor *big.Int, transactionOptions ...chainutil.TransactionOptions, ) (*types.Transaction, error) { bLogger.Debug( - "submitting transaction ecdsaWalletCreatedCallback", + "submitting transaction initialize", " params: ", fmt.Sprint( - arg_ecdsaWalletID, - arg_publicKeyX, - arg_publicKeyY, + arg__bank, + arg__relay, + arg__treasury, + arg__ecdsaWalletRegistry, + arg__reimbursementPool, + arg__txProofDifficultyFactor, ), ) @@ -450,26 +446,32 @@ func (b *Bridge) EcdsaWalletCreatedCallback( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := b.contract.EcdsaWalletCreatedCallback( + transaction, err := b.contract.Initialize( transactorOptions, - arg_ecdsaWalletID, - arg_publicKeyX, - arg_publicKeyY, + arg__bank, + arg__relay, + arg__treasury, + arg__ecdsaWalletRegistry, + arg__reimbursementPool, + arg__txProofDifficultyFactor, ) if err != nil { return transaction, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "ecdsaWalletCreatedCallback", - arg_ecdsaWalletID, - arg_publicKeyX, - arg_publicKeyY, + "initialize", + arg__bank, + arg__relay, + arg__treasury, + arg__ecdsaWalletRegistry, + arg__reimbursementPool, + arg__txProofDifficultyFactor, ) } bLogger.Infof( - "submitted transaction ecdsaWalletCreatedCallback with id: [%s] and nonce [%v]", + "submitted transaction initialize with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -488,26 +490,32 @@ func (b *Bridge) EcdsaWalletCreatedCallback( newTransactorOptions.GasLimit = transactorOptions.GasLimit } - transaction, err := b.contract.EcdsaWalletCreatedCallback( + transaction, err := b.contract.Initialize( newTransactorOptions, - arg_ecdsaWalletID, - arg_publicKeyX, - arg_publicKeyY, + arg__bank, + arg__relay, + arg__treasury, + arg__ecdsaWalletRegistry, + arg__reimbursementPool, + arg__txProofDifficultyFactor, ) if err != nil { return nil, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "ecdsaWalletCreatedCallback", - arg_ecdsaWalletID, - arg_publicKeyX, - arg_publicKeyY, + "initialize", + arg__bank, + arg__relay, + arg__treasury, + arg__ecdsaWalletRegistry, + arg__reimbursementPool, + arg__txProofDifficultyFactor, ) } bLogger.Infof( - "submitted transaction ecdsaWalletCreatedCallback with id: [%s] and nonce [%v]", + "submitted transaction initialize with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -522,10 +530,13 @@ func (b *Bridge) EcdsaWalletCreatedCallback( } // Non-mutating call, not a transaction submission. -func (b *Bridge) CallEcdsaWalletCreatedCallback( - arg_ecdsaWalletID [32]byte, - arg_publicKeyX [32]byte, - arg_publicKeyY [32]byte, +func (b *Bridge) CallInitialize( + arg__bank common.Address, + arg__relay common.Address, + arg__treasury common.Address, + arg__ecdsaWalletRegistry common.Address, + arg__reimbursementPool common.Address, + arg__txProofDifficultyFactor *big.Int, blockNumber *big.Int, ) error { var result interface{} = nil @@ -537,53 +548,53 @@ func (b *Bridge) CallEcdsaWalletCreatedCallback( b.caller, b.errorResolver, b.contractAddress, - "ecdsaWalletCreatedCallback", + "initialize", &result, - arg_ecdsaWalletID, - arg_publicKeyX, - arg_publicKeyY, + arg__bank, + arg__relay, + arg__treasury, + arg__ecdsaWalletRegistry, + arg__reimbursementPool, + arg__txProofDifficultyFactor, ) return err } -func (b *Bridge) EcdsaWalletCreatedCallbackGasEstimate( - arg_ecdsaWalletID [32]byte, - arg_publicKeyX [32]byte, - arg_publicKeyY [32]byte, +func (b *Bridge) InitializeGasEstimate( + arg__bank common.Address, + arg__relay common.Address, + arg__treasury common.Address, + arg__ecdsaWalletRegistry common.Address, + arg__reimbursementPool common.Address, + arg__txProofDifficultyFactor *big.Int, ) (uint64, error) { var result uint64 result, err := chainutil.EstimateGas( b.callerOptions.From, b.contractAddress, - "ecdsaWalletCreatedCallback", + "initialize", b.contractABI, b.transactor, - arg_ecdsaWalletID, - arg_publicKeyX, - arg_publicKeyY, + arg__bank, + arg__relay, + arg__treasury, + arg__ecdsaWalletRegistry, + arg__reimbursementPool, + arg__txProofDifficultyFactor, ) return result, err } // Transaction submission. -func (b *Bridge) EcdsaWalletHeartbeatFailedCallback( - arg0 [32]byte, - arg_publicKeyX [32]byte, - arg_publicKeyY [32]byte, +func (b *Bridge) InitializeV2FixVaultZeroDeposit( transactionOptions ...chainutil.TransactionOptions, ) (*types.Transaction, error) { bLogger.Debug( - "submitting transaction ecdsaWalletHeartbeatFailedCallback", - " params: ", - fmt.Sprint( - arg0, - arg_publicKeyX, - arg_publicKeyY, - ), + "submitting transaction initializeV2FixVaultZeroDeposit", ) b.transactionMutex.Lock() @@ -608,26 +619,20 @@ func (b *Bridge) EcdsaWalletHeartbeatFailedCallback( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := b.contract.EcdsaWalletHeartbeatFailedCallback( + transaction, err := b.contract.InitializeV2FixVaultZeroDeposit( transactorOptions, - arg0, - arg_publicKeyX, - arg_publicKeyY, ) if err != nil { return transaction, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "ecdsaWalletHeartbeatFailedCallback", - arg0, - arg_publicKeyX, - arg_publicKeyY, + "initializeV2FixVaultZeroDeposit", ) } bLogger.Infof( - "submitted transaction ecdsaWalletHeartbeatFailedCallback with id: [%s] and nonce [%v]", + "submitted transaction initializeV2FixVaultZeroDeposit with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -646,26 +651,20 @@ func (b *Bridge) EcdsaWalletHeartbeatFailedCallback( newTransactorOptions.GasLimit = transactorOptions.GasLimit } - transaction, err := b.contract.EcdsaWalletHeartbeatFailedCallback( + transaction, err := b.contract.InitializeV2FixVaultZeroDeposit( newTransactorOptions, - arg0, - arg_publicKeyX, - arg_publicKeyY, ) if err != nil { return nil, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "ecdsaWalletHeartbeatFailedCallback", - arg0, - arg_publicKeyX, - arg_publicKeyY, + "initializeV2FixVaultZeroDeposit", ) } bLogger.Infof( - "submitted transaction ecdsaWalletHeartbeatFailedCallback with id: [%s] and nonce [%v]", + "submitted transaction initializeV2FixVaultZeroDeposit with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -680,10 +679,7 @@ func (b *Bridge) EcdsaWalletHeartbeatFailedCallback( } // Non-mutating call, not a transaction submission. -func (b *Bridge) CallEcdsaWalletHeartbeatFailedCallback( - arg0 [32]byte, - arg_publicKeyX [32]byte, - arg_publicKeyY [32]byte, +func (b *Bridge) CallInitializeV2FixVaultZeroDeposit( blockNumber *big.Int, ) error { var result interface{} = nil @@ -695,58 +691,40 @@ func (b *Bridge) CallEcdsaWalletHeartbeatFailedCallback( b.caller, b.errorResolver, b.contractAddress, - "ecdsaWalletHeartbeatFailedCallback", + "initializeV2FixVaultZeroDeposit", &result, - arg0, - arg_publicKeyX, - arg_publicKeyY, ) return err } -func (b *Bridge) EcdsaWalletHeartbeatFailedCallbackGasEstimate( - arg0 [32]byte, - arg_publicKeyX [32]byte, - arg_publicKeyY [32]byte, -) (uint64, error) { +func (b *Bridge) InitializeV2FixVaultZeroDepositGasEstimate() (uint64, error) { var result uint64 result, err := chainutil.EstimateGas( b.callerOptions.From, b.contractAddress, - "ecdsaWalletHeartbeatFailedCallback", + "initializeV2FixVaultZeroDeposit", b.contractABI, b.transactor, - arg0, - arg_publicKeyX, - arg_publicKeyY, ) return result, err } // Transaction submission. -func (b *Bridge) Initialize( - arg__bank common.Address, - arg__relay common.Address, - arg__treasury common.Address, - arg__ecdsaWalletRegistry common.Address, - arg__reimbursementPool common.Address, - arg__txProofDifficultyFactor *big.Int, +func (b *Bridge) MigrateLegacyFraudChallenges( + arg_routerKind uint8, + arg_challengeKeys []*big.Int, transactionOptions ...chainutil.TransactionOptions, ) (*types.Transaction, error) { bLogger.Debug( - "submitting transaction initialize", + "submitting transaction migrateLegacyFraudChallenges", " params: ", fmt.Sprint( - arg__bank, - arg__relay, - arg__treasury, - arg__ecdsaWalletRegistry, - arg__reimbursementPool, - arg__txProofDifficultyFactor, + arg_routerKind, + arg_challengeKeys, ), ) @@ -772,32 +750,24 @@ func (b *Bridge) Initialize( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := b.contract.Initialize( + transaction, err := b.contract.MigrateLegacyFraudChallenges( transactorOptions, - arg__bank, - arg__relay, - arg__treasury, - arg__ecdsaWalletRegistry, - arg__reimbursementPool, - arg__txProofDifficultyFactor, + arg_routerKind, + arg_challengeKeys, ) if err != nil { return transaction, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "initialize", - arg__bank, - arg__relay, - arg__treasury, - arg__ecdsaWalletRegistry, - arg__reimbursementPool, - arg__txProofDifficultyFactor, + "migrateLegacyFraudChallenges", + arg_routerKind, + arg_challengeKeys, ) } bLogger.Infof( - "submitted transaction initialize with id: [%s] and nonce [%v]", + "submitted transaction migrateLegacyFraudChallenges with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -816,32 +786,24 @@ func (b *Bridge) Initialize( newTransactorOptions.GasLimit = transactorOptions.GasLimit } - transaction, err := b.contract.Initialize( + transaction, err := b.contract.MigrateLegacyFraudChallenges( newTransactorOptions, - arg__bank, - arg__relay, - arg__treasury, - arg__ecdsaWalletRegistry, - arg__reimbursementPool, - arg__txProofDifficultyFactor, + arg_routerKind, + arg_challengeKeys, ) if err != nil { return nil, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "initialize", - arg__bank, - arg__relay, - arg__treasury, - arg__ecdsaWalletRegistry, - arg__reimbursementPool, - arg__txProofDifficultyFactor, + "migrateLegacyFraudChallenges", + arg_routerKind, + arg_challengeKeys, ) } bLogger.Infof( - "submitted transaction initialize with id: [%s] and nonce [%v]", + "submitted transaction migrateLegacyFraudChallenges with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -856,13 +818,9 @@ func (b *Bridge) Initialize( } // Non-mutating call, not a transaction submission. -func (b *Bridge) CallInitialize( - arg__bank common.Address, - arg__relay common.Address, - arg__treasury common.Address, - arg__ecdsaWalletRegistry common.Address, - arg__reimbursementPool common.Address, - arg__txProofDifficultyFactor *big.Int, +func (b *Bridge) CallMigrateLegacyFraudChallenges( + arg_routerKind uint8, + arg_challengeKeys []*big.Int, blockNumber *big.Int, ) error { var result interface{} = nil @@ -874,53 +832,50 @@ func (b *Bridge) CallInitialize( b.caller, b.errorResolver, b.contractAddress, - "initialize", + "migrateLegacyFraudChallenges", &result, - arg__bank, - arg__relay, - arg__treasury, - arg__ecdsaWalletRegistry, - arg__reimbursementPool, - arg__txProofDifficultyFactor, + arg_routerKind, + arg_challengeKeys, ) return err } -func (b *Bridge) InitializeGasEstimate( - arg__bank common.Address, - arg__relay common.Address, - arg__treasury common.Address, - arg__ecdsaWalletRegistry common.Address, - arg__reimbursementPool common.Address, - arg__txProofDifficultyFactor *big.Int, +func (b *Bridge) MigrateLegacyFraudChallengesGasEstimate( + arg_routerKind uint8, + arg_challengeKeys []*big.Int, ) (uint64, error) { var result uint64 result, err := chainutil.EstimateGas( b.callerOptions.From, b.contractAddress, - "initialize", + "migrateLegacyFraudChallenges", b.contractABI, b.transactor, - arg__bank, - arg__relay, - arg__treasury, - arg__ecdsaWalletRegistry, - arg__reimbursementPool, - arg__txProofDifficultyFactor, + arg_routerKind, + arg_challengeKeys, ) return result, err } // Transaction submission. -func (b *Bridge) InitializeV2FixVaultZeroDeposit( +func (b *Bridge) NotifyMovedFundsSweepTimeout( + arg_movingFundsTxHash [32]byte, + arg_movingFundsTxOutputIndex uint32, + arg_walletMembersIDs []uint32, transactionOptions ...chainutil.TransactionOptions, ) (*types.Transaction, error) { bLogger.Debug( - "submitting transaction initializeV2FixVaultZeroDeposit", + "submitting transaction notifyMovedFundsSweepTimeout", + " params: ", + fmt.Sprint( + arg_movingFundsTxHash, + arg_movingFundsTxOutputIndex, + arg_walletMembersIDs, + ), ) b.transactionMutex.Lock() @@ -945,20 +900,26 @@ func (b *Bridge) InitializeV2FixVaultZeroDeposit( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := b.contract.InitializeV2FixVaultZeroDeposit( + transaction, err := b.contract.NotifyMovedFundsSweepTimeout( transactorOptions, + arg_movingFundsTxHash, + arg_movingFundsTxOutputIndex, + arg_walletMembersIDs, ) if err != nil { return transaction, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "initializeV2FixVaultZeroDeposit", + "notifyMovedFundsSweepTimeout", + arg_movingFundsTxHash, + arg_movingFundsTxOutputIndex, + arg_walletMembersIDs, ) } bLogger.Infof( - "submitted transaction initializeV2FixVaultZeroDeposit with id: [%s] and nonce [%v]", + "submitted transaction notifyMovedFundsSweepTimeout with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -977,20 +938,26 @@ func (b *Bridge) InitializeV2FixVaultZeroDeposit( newTransactorOptions.GasLimit = transactorOptions.GasLimit } - transaction, err := b.contract.InitializeV2FixVaultZeroDeposit( + transaction, err := b.contract.NotifyMovedFundsSweepTimeout( newTransactorOptions, + arg_movingFundsTxHash, + arg_movingFundsTxOutputIndex, + arg_walletMembersIDs, ) if err != nil { return nil, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "initializeV2FixVaultZeroDeposit", + "notifyMovedFundsSweepTimeout", + arg_movingFundsTxHash, + arg_movingFundsTxOutputIndex, + arg_walletMembersIDs, ) } bLogger.Infof( - "submitted transaction initializeV2FixVaultZeroDeposit with id: [%s] and nonce [%v]", + "submitted transaction notifyMovedFundsSweepTimeout with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -1005,7 +972,10 @@ func (b *Bridge) InitializeV2FixVaultZeroDeposit( } // Non-mutating call, not a transaction submission. -func (b *Bridge) CallInitializeV2FixVaultZeroDeposit( +func (b *Bridge) CallNotifyMovedFundsSweepTimeout( + arg_movingFundsTxHash [32]byte, + arg_movingFundsTxOutputIndex uint32, + arg_walletMembersIDs []uint32, blockNumber *big.Int, ) error { var result interface{} = nil @@ -1017,42 +987,50 @@ func (b *Bridge) CallInitializeV2FixVaultZeroDeposit( b.caller, b.errorResolver, b.contractAddress, - "initializeV2FixVaultZeroDeposit", + "notifyMovedFundsSweepTimeout", &result, + arg_movingFundsTxHash, + arg_movingFundsTxOutputIndex, + arg_walletMembersIDs, ) return err } -func (b *Bridge) InitializeV2FixVaultZeroDepositGasEstimate() (uint64, error) { +func (b *Bridge) NotifyMovedFundsSweepTimeoutGasEstimate( + arg_movingFundsTxHash [32]byte, + arg_movingFundsTxOutputIndex uint32, + arg_walletMembersIDs []uint32, +) (uint64, error) { var result uint64 result, err := chainutil.EstimateGas( b.callerOptions.From, b.contractAddress, - "initializeV2FixVaultZeroDeposit", + "notifyMovedFundsSweepTimeout", b.contractABI, b.transactor, + arg_movingFundsTxHash, + arg_movingFundsTxOutputIndex, + arg_walletMembersIDs, ) return result, err } // Transaction submission. -func (b *Bridge) NotifyFraudChallengeDefeatTimeout( - arg_walletPublicKey []byte, - arg_walletMembersIDs []uint32, - arg_preimageSha256 []byte, +func (b *Bridge) NotifyMovingFundsBelowDust( + arg_walletPubKeyHash [20]byte, + arg_mainUtxo abi.BitcoinTxUTXO, transactionOptions ...chainutil.TransactionOptions, ) (*types.Transaction, error) { bLogger.Debug( - "submitting transaction notifyFraudChallengeDefeatTimeout", + "submitting transaction notifyMovingFundsBelowDust", " params: ", fmt.Sprint( - arg_walletPublicKey, - arg_walletMembersIDs, - arg_preimageSha256, + arg_walletPubKeyHash, + arg_mainUtxo, ), ) @@ -1078,26 +1056,24 @@ func (b *Bridge) NotifyFraudChallengeDefeatTimeout( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := b.contract.NotifyFraudChallengeDefeatTimeout( + transaction, err := b.contract.NotifyMovingFundsBelowDust( transactorOptions, - arg_walletPublicKey, - arg_walletMembersIDs, - arg_preimageSha256, + arg_walletPubKeyHash, + arg_mainUtxo, ) if err != nil { return transaction, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "notifyFraudChallengeDefeatTimeout", - arg_walletPublicKey, - arg_walletMembersIDs, - arg_preimageSha256, + "notifyMovingFundsBelowDust", + arg_walletPubKeyHash, + arg_mainUtxo, ) } bLogger.Infof( - "submitted transaction notifyFraudChallengeDefeatTimeout with id: [%s] and nonce [%v]", + "submitted transaction notifyMovingFundsBelowDust with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -1116,26 +1092,24 @@ func (b *Bridge) NotifyFraudChallengeDefeatTimeout( newTransactorOptions.GasLimit = transactorOptions.GasLimit } - transaction, err := b.contract.NotifyFraudChallengeDefeatTimeout( + transaction, err := b.contract.NotifyMovingFundsBelowDust( newTransactorOptions, - arg_walletPublicKey, - arg_walletMembersIDs, - arg_preimageSha256, + arg_walletPubKeyHash, + arg_mainUtxo, ) if err != nil { return nil, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "notifyFraudChallengeDefeatTimeout", - arg_walletPublicKey, - arg_walletMembersIDs, - arg_preimageSha256, + "notifyMovingFundsBelowDust", + arg_walletPubKeyHash, + arg_mainUtxo, ) } bLogger.Infof( - "submitted transaction notifyFraudChallengeDefeatTimeout with id: [%s] and nonce [%v]", + "submitted transaction notifyMovingFundsBelowDust with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -1150,10 +1124,9 @@ func (b *Bridge) NotifyFraudChallengeDefeatTimeout( } // Non-mutating call, not a transaction submission. -func (b *Bridge) CallNotifyFraudChallengeDefeatTimeout( - arg_walletPublicKey []byte, - arg_walletMembersIDs []uint32, - arg_preimageSha256 []byte, +func (b *Bridge) CallNotifyMovingFundsBelowDust( + arg_walletPubKeyHash [20]byte, + arg_mainUtxo abi.BitcoinTxUTXO, blockNumber *big.Int, ) error { var result interface{} = nil @@ -1165,51 +1138,46 @@ func (b *Bridge) CallNotifyFraudChallengeDefeatTimeout( b.caller, b.errorResolver, b.contractAddress, - "notifyFraudChallengeDefeatTimeout", + "notifyMovingFundsBelowDust", &result, - arg_walletPublicKey, - arg_walletMembersIDs, - arg_preimageSha256, + arg_walletPubKeyHash, + arg_mainUtxo, ) return err } -func (b *Bridge) NotifyFraudChallengeDefeatTimeoutGasEstimate( - arg_walletPublicKey []byte, - arg_walletMembersIDs []uint32, - arg_preimageSha256 []byte, +func (b *Bridge) NotifyMovingFundsBelowDustGasEstimate( + arg_walletPubKeyHash [20]byte, + arg_mainUtxo abi.BitcoinTxUTXO, ) (uint64, error) { var result uint64 result, err := chainutil.EstimateGas( b.callerOptions.From, b.contractAddress, - "notifyFraudChallengeDefeatTimeout", + "notifyMovingFundsBelowDust", b.contractABI, b.transactor, - arg_walletPublicKey, - arg_walletMembersIDs, - arg_preimageSha256, + arg_walletPubKeyHash, + arg_mainUtxo, ) return result, err } // Transaction submission. -func (b *Bridge) NotifyMovedFundsSweepTimeout( - arg_movingFundsTxHash [32]byte, - arg_movingFundsTxOutputIndex uint32, +func (b *Bridge) NotifyMovingFundsTimeout( + arg_walletPubKeyHash [20]byte, arg_walletMembersIDs []uint32, transactionOptions ...chainutil.TransactionOptions, ) (*types.Transaction, error) { bLogger.Debug( - "submitting transaction notifyMovedFundsSweepTimeout", + "submitting transaction notifyMovingFundsTimeout", " params: ", fmt.Sprint( - arg_movingFundsTxHash, - arg_movingFundsTxOutputIndex, + arg_walletPubKeyHash, arg_walletMembersIDs, ), ) @@ -1236,10 +1204,9 @@ func (b *Bridge) NotifyMovedFundsSweepTimeout( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := b.contract.NotifyMovedFundsSweepTimeout( + transaction, err := b.contract.NotifyMovingFundsTimeout( transactorOptions, - arg_movingFundsTxHash, - arg_movingFundsTxOutputIndex, + arg_walletPubKeyHash, arg_walletMembersIDs, ) if err != nil { @@ -1247,15 +1214,14 @@ func (b *Bridge) NotifyMovedFundsSweepTimeout( err, b.transactorOptions.From, nil, - "notifyMovedFundsSweepTimeout", - arg_movingFundsTxHash, - arg_movingFundsTxOutputIndex, + "notifyMovingFundsTimeout", + arg_walletPubKeyHash, arg_walletMembersIDs, ) } bLogger.Infof( - "submitted transaction notifyMovedFundsSweepTimeout with id: [%s] and nonce [%v]", + "submitted transaction notifyMovingFundsTimeout with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -1274,10 +1240,9 @@ func (b *Bridge) NotifyMovedFundsSweepTimeout( newTransactorOptions.GasLimit = transactorOptions.GasLimit } - transaction, err := b.contract.NotifyMovedFundsSweepTimeout( + transaction, err := b.contract.NotifyMovingFundsTimeout( newTransactorOptions, - arg_movingFundsTxHash, - arg_movingFundsTxOutputIndex, + arg_walletPubKeyHash, arg_walletMembersIDs, ) if err != nil { @@ -1285,15 +1250,14 @@ func (b *Bridge) NotifyMovedFundsSweepTimeout( err, b.transactorOptions.From, nil, - "notifyMovedFundsSweepTimeout", - arg_movingFundsTxHash, - arg_movingFundsTxOutputIndex, + "notifyMovingFundsTimeout", + arg_walletPubKeyHash, arg_walletMembersIDs, ) } bLogger.Infof( - "submitted transaction notifyMovedFundsSweepTimeout with id: [%s] and nonce [%v]", + "submitted transaction notifyMovingFundsTimeout with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -1308,9 +1272,8 @@ func (b *Bridge) NotifyMovedFundsSweepTimeout( } // Non-mutating call, not a transaction submission. -func (b *Bridge) CallNotifyMovedFundsSweepTimeout( - arg_movingFundsTxHash [32]byte, - arg_movingFundsTxOutputIndex uint32, +func (b *Bridge) CallNotifyMovingFundsTimeout( + arg_walletPubKeyHash [20]byte, arg_walletMembersIDs []uint32, blockNumber *big.Int, ) error { @@ -1323,19 +1286,17 @@ func (b *Bridge) CallNotifyMovedFundsSweepTimeout( b.caller, b.errorResolver, b.contractAddress, - "notifyMovedFundsSweepTimeout", + "notifyMovingFundsTimeout", &result, - arg_movingFundsTxHash, - arg_movingFundsTxOutputIndex, + arg_walletPubKeyHash, arg_walletMembersIDs, ) return err } -func (b *Bridge) NotifyMovedFundsSweepTimeoutGasEstimate( - arg_movingFundsTxHash [32]byte, - arg_movingFundsTxOutputIndex uint32, +func (b *Bridge) NotifyMovingFundsTimeoutGasEstimate( + arg_walletPubKeyHash [20]byte, arg_walletMembersIDs []uint32, ) (uint64, error) { var result uint64 @@ -1343,11 +1304,10 @@ func (b *Bridge) NotifyMovedFundsSweepTimeoutGasEstimate( result, err := chainutil.EstimateGas( b.callerOptions.From, b.contractAddress, - "notifyMovedFundsSweepTimeout", + "notifyMovingFundsTimeout", b.contractABI, b.transactor, - arg_movingFundsTxHash, - arg_movingFundsTxOutputIndex, + arg_walletPubKeyHash, arg_walletMembersIDs, ) @@ -1355,18 +1315,20 @@ func (b *Bridge) NotifyMovedFundsSweepTimeoutGasEstimate( } // Transaction submission. -func (b *Bridge) NotifyMovingFundsBelowDust( +func (b *Bridge) NotifyRedemptionTimeout( arg_walletPubKeyHash [20]byte, - arg_mainUtxo abi.BitcoinTxUTXO, + arg_walletMembersIDs []uint32, + arg_redeemerOutputScript []byte, transactionOptions ...chainutil.TransactionOptions, ) (*types.Transaction, error) { bLogger.Debug( - "submitting transaction notifyMovingFundsBelowDust", + "submitting transaction notifyRedemptionTimeout", " params: ", fmt.Sprint( arg_walletPubKeyHash, - arg_mainUtxo, + arg_walletMembersIDs, + arg_redeemerOutputScript, ), ) @@ -1392,24 +1354,26 @@ func (b *Bridge) NotifyMovingFundsBelowDust( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := b.contract.NotifyMovingFundsBelowDust( + transaction, err := b.contract.NotifyRedemptionTimeout( transactorOptions, arg_walletPubKeyHash, - arg_mainUtxo, + arg_walletMembersIDs, + arg_redeemerOutputScript, ) if err != nil { return transaction, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "notifyMovingFundsBelowDust", + "notifyRedemptionTimeout", arg_walletPubKeyHash, - arg_mainUtxo, + arg_walletMembersIDs, + arg_redeemerOutputScript, ) } bLogger.Infof( - "submitted transaction notifyMovingFundsBelowDust with id: [%s] and nonce [%v]", + "submitted transaction notifyRedemptionTimeout with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -1428,24 +1392,26 @@ func (b *Bridge) NotifyMovingFundsBelowDust( newTransactorOptions.GasLimit = transactorOptions.GasLimit } - transaction, err := b.contract.NotifyMovingFundsBelowDust( + transaction, err := b.contract.NotifyRedemptionTimeout( newTransactorOptions, arg_walletPubKeyHash, - arg_mainUtxo, + arg_walletMembersIDs, + arg_redeemerOutputScript, ) if err != nil { return nil, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "notifyMovingFundsBelowDust", + "notifyRedemptionTimeout", arg_walletPubKeyHash, - arg_mainUtxo, + arg_walletMembersIDs, + arg_redeemerOutputScript, ) } bLogger.Infof( - "submitted transaction notifyMovingFundsBelowDust with id: [%s] and nonce [%v]", + "submitted transaction notifyRedemptionTimeout with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -1460,9 +1426,10 @@ func (b *Bridge) NotifyMovingFundsBelowDust( } // Non-mutating call, not a transaction submission. -func (b *Bridge) CallNotifyMovingFundsBelowDust( +func (b *Bridge) CallNotifyRedemptionTimeout( arg_walletPubKeyHash [20]byte, - arg_mainUtxo abi.BitcoinTxUTXO, + arg_walletMembersIDs []uint32, + arg_redeemerOutputScript []byte, blockNumber *big.Int, ) error { var result interface{} = nil @@ -1474,47 +1441,50 @@ func (b *Bridge) CallNotifyMovingFundsBelowDust( b.caller, b.errorResolver, b.contractAddress, - "notifyMovingFundsBelowDust", + "notifyRedemptionTimeout", &result, arg_walletPubKeyHash, - arg_mainUtxo, + arg_walletMembersIDs, + arg_redeemerOutputScript, ) return err } -func (b *Bridge) NotifyMovingFundsBelowDustGasEstimate( +func (b *Bridge) NotifyRedemptionTimeoutGasEstimate( arg_walletPubKeyHash [20]byte, - arg_mainUtxo abi.BitcoinTxUTXO, + arg_walletMembersIDs []uint32, + arg_redeemerOutputScript []byte, ) (uint64, error) { var result uint64 result, err := chainutil.EstimateGas( b.callerOptions.From, b.contractAddress, - "notifyMovingFundsBelowDust", + "notifyRedemptionTimeout", b.contractABI, b.transactor, arg_walletPubKeyHash, - arg_mainUtxo, + arg_walletMembersIDs, + arg_redeemerOutputScript, ) return result, err } // Transaction submission. -func (b *Bridge) NotifyMovingFundsTimeout( +func (b *Bridge) NotifyRedemptionVeto( arg_walletPubKeyHash [20]byte, - arg_walletMembersIDs []uint32, + arg_redeemerOutputScript []byte, transactionOptions ...chainutil.TransactionOptions, ) (*types.Transaction, error) { bLogger.Debug( - "submitting transaction notifyMovingFundsTimeout", + "submitting transaction notifyRedemptionVeto", " params: ", fmt.Sprint( arg_walletPubKeyHash, - arg_walletMembersIDs, + arg_redeemerOutputScript, ), ) @@ -1540,24 +1510,24 @@ func (b *Bridge) NotifyMovingFundsTimeout( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := b.contract.NotifyMovingFundsTimeout( + transaction, err := b.contract.NotifyRedemptionVeto( transactorOptions, arg_walletPubKeyHash, - arg_walletMembersIDs, + arg_redeemerOutputScript, ) if err != nil { return transaction, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "notifyMovingFundsTimeout", + "notifyRedemptionVeto", arg_walletPubKeyHash, - arg_walletMembersIDs, + arg_redeemerOutputScript, ) } bLogger.Infof( - "submitted transaction notifyMovingFundsTimeout with id: [%s] and nonce [%v]", + "submitted transaction notifyRedemptionVeto with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -1576,24 +1546,24 @@ func (b *Bridge) NotifyMovingFundsTimeout( newTransactorOptions.GasLimit = transactorOptions.GasLimit } - transaction, err := b.contract.NotifyMovingFundsTimeout( + transaction, err := b.contract.NotifyRedemptionVeto( newTransactorOptions, arg_walletPubKeyHash, - arg_walletMembersIDs, + arg_redeemerOutputScript, ) if err != nil { return nil, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "notifyMovingFundsTimeout", + "notifyRedemptionVeto", arg_walletPubKeyHash, - arg_walletMembersIDs, + arg_redeemerOutputScript, ) } bLogger.Infof( - "submitted transaction notifyMovingFundsTimeout with id: [%s] and nonce [%v]", + "submitted transaction notifyRedemptionVeto with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -1608,9 +1578,9 @@ func (b *Bridge) NotifyMovingFundsTimeout( } // Non-mutating call, not a transaction submission. -func (b *Bridge) CallNotifyMovingFundsTimeout( +func (b *Bridge) CallNotifyRedemptionVeto( arg_walletPubKeyHash [20]byte, - arg_walletMembersIDs []uint32, + arg_redeemerOutputScript []byte, blockNumber *big.Int, ) error { var result interface{} = nil @@ -1622,49 +1592,47 @@ func (b *Bridge) CallNotifyMovingFundsTimeout( b.caller, b.errorResolver, b.contractAddress, - "notifyMovingFundsTimeout", + "notifyRedemptionVeto", &result, arg_walletPubKeyHash, - arg_walletMembersIDs, + arg_redeemerOutputScript, ) return err } -func (b *Bridge) NotifyMovingFundsTimeoutGasEstimate( +func (b *Bridge) NotifyRedemptionVetoGasEstimate( arg_walletPubKeyHash [20]byte, - arg_walletMembersIDs []uint32, + arg_redeemerOutputScript []byte, ) (uint64, error) { var result uint64 result, err := chainutil.EstimateGas( b.callerOptions.From, b.contractAddress, - "notifyMovingFundsTimeout", + "notifyRedemptionVeto", b.contractABI, b.transactor, arg_walletPubKeyHash, - arg_walletMembersIDs, + arg_redeemerOutputScript, ) return result, err } // Transaction submission. -func (b *Bridge) NotifyRedemptionTimeout( +func (b *Bridge) NotifyWalletCloseable( arg_walletPubKeyHash [20]byte, - arg_walletMembersIDs []uint32, - arg_redeemerOutputScript []byte, + arg_walletMainUtxo abi.BitcoinTxUTXO, transactionOptions ...chainutil.TransactionOptions, ) (*types.Transaction, error) { bLogger.Debug( - "submitting transaction notifyRedemptionTimeout", + "submitting transaction notifyWalletCloseable", " params: ", fmt.Sprint( arg_walletPubKeyHash, - arg_walletMembersIDs, - arg_redeemerOutputScript, + arg_walletMainUtxo, ), ) @@ -1690,26 +1658,24 @@ func (b *Bridge) NotifyRedemptionTimeout( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := b.contract.NotifyRedemptionTimeout( + transaction, err := b.contract.NotifyWalletCloseable( transactorOptions, arg_walletPubKeyHash, - arg_walletMembersIDs, - arg_redeemerOutputScript, + arg_walletMainUtxo, ) if err != nil { return transaction, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "notifyRedemptionTimeout", + "notifyWalletCloseable", arg_walletPubKeyHash, - arg_walletMembersIDs, - arg_redeemerOutputScript, + arg_walletMainUtxo, ) } bLogger.Infof( - "submitted transaction notifyRedemptionTimeout with id: [%s] and nonce [%v]", + "submitted transaction notifyWalletCloseable with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -1728,26 +1694,24 @@ func (b *Bridge) NotifyRedemptionTimeout( newTransactorOptions.GasLimit = transactorOptions.GasLimit } - transaction, err := b.contract.NotifyRedemptionTimeout( + transaction, err := b.contract.NotifyWalletCloseable( newTransactorOptions, arg_walletPubKeyHash, - arg_walletMembersIDs, - arg_redeemerOutputScript, + arg_walletMainUtxo, ) if err != nil { return nil, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "notifyRedemptionTimeout", + "notifyWalletCloseable", arg_walletPubKeyHash, - arg_walletMembersIDs, - arg_redeemerOutputScript, + arg_walletMainUtxo, ) } bLogger.Infof( - "submitted transaction notifyRedemptionTimeout with id: [%s] and nonce [%v]", + "submitted transaction notifyWalletCloseable with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -1762,10 +1726,9 @@ func (b *Bridge) NotifyRedemptionTimeout( } // Non-mutating call, not a transaction submission. -func (b *Bridge) CallNotifyRedemptionTimeout( +func (b *Bridge) CallNotifyWalletCloseable( arg_walletPubKeyHash [20]byte, - arg_walletMembersIDs []uint32, - arg_redeemerOutputScript []byte, + arg_walletMainUtxo abi.BitcoinTxUTXO, blockNumber *big.Int, ) error { var result interface{} = nil @@ -1777,50 +1740,45 @@ func (b *Bridge) CallNotifyRedemptionTimeout( b.caller, b.errorResolver, b.contractAddress, - "notifyRedemptionTimeout", + "notifyWalletCloseable", &result, arg_walletPubKeyHash, - arg_walletMembersIDs, - arg_redeemerOutputScript, + arg_walletMainUtxo, ) return err } -func (b *Bridge) NotifyRedemptionTimeoutGasEstimate( +func (b *Bridge) NotifyWalletCloseableGasEstimate( arg_walletPubKeyHash [20]byte, - arg_walletMembersIDs []uint32, - arg_redeemerOutputScript []byte, + arg_walletMainUtxo abi.BitcoinTxUTXO, ) (uint64, error) { var result uint64 result, err := chainutil.EstimateGas( b.callerOptions.From, b.contractAddress, - "notifyRedemptionTimeout", + "notifyWalletCloseable", b.contractABI, b.transactor, arg_walletPubKeyHash, - arg_walletMembersIDs, - arg_redeemerOutputScript, + arg_walletMainUtxo, ) return result, err } // Transaction submission. -func (b *Bridge) NotifyRedemptionVeto( +func (b *Bridge) NotifyWalletClosingPeriodElapsed( arg_walletPubKeyHash [20]byte, - arg_redeemerOutputScript []byte, transactionOptions ...chainutil.TransactionOptions, ) (*types.Transaction, error) { bLogger.Debug( - "submitting transaction notifyRedemptionVeto", + "submitting transaction notifyWalletClosingPeriodElapsed", " params: ", fmt.Sprint( arg_walletPubKeyHash, - arg_redeemerOutputScript, ), ) @@ -1846,24 +1804,22 @@ func (b *Bridge) NotifyRedemptionVeto( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := b.contract.NotifyRedemptionVeto( + transaction, err := b.contract.NotifyWalletClosingPeriodElapsed( transactorOptions, arg_walletPubKeyHash, - arg_redeemerOutputScript, ) if err != nil { return transaction, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "notifyRedemptionVeto", + "notifyWalletClosingPeriodElapsed", arg_walletPubKeyHash, - arg_redeemerOutputScript, ) } bLogger.Infof( - "submitted transaction notifyRedemptionVeto with id: [%s] and nonce [%v]", + "submitted transaction notifyWalletClosingPeriodElapsed with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -1882,24 +1838,22 @@ func (b *Bridge) NotifyRedemptionVeto( newTransactorOptions.GasLimit = transactorOptions.GasLimit } - transaction, err := b.contract.NotifyRedemptionVeto( + transaction, err := b.contract.NotifyWalletClosingPeriodElapsed( newTransactorOptions, arg_walletPubKeyHash, - arg_redeemerOutputScript, ) if err != nil { return nil, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "notifyRedemptionVeto", + "notifyWalletClosingPeriodElapsed", arg_walletPubKeyHash, - arg_redeemerOutputScript, ) } bLogger.Infof( - "submitted transaction notifyRedemptionVeto with id: [%s] and nonce [%v]", + "submitted transaction notifyWalletClosingPeriodElapsed with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -1914,9 +1868,8 @@ func (b *Bridge) NotifyRedemptionVeto( } // Non-mutating call, not a transaction submission. -func (b *Bridge) CallNotifyRedemptionVeto( +func (b *Bridge) CallNotifyWalletClosingPeriodElapsed( arg_walletPubKeyHash [20]byte, - arg_redeemerOutputScript []byte, blockNumber *big.Int, ) error { var result interface{} = nil @@ -1928,47 +1881,46 @@ func (b *Bridge) CallNotifyRedemptionVeto( b.caller, b.errorResolver, b.contractAddress, - "notifyRedemptionVeto", + "notifyWalletClosingPeriodElapsed", &result, arg_walletPubKeyHash, - arg_redeemerOutputScript, ) return err } -func (b *Bridge) NotifyRedemptionVetoGasEstimate( +func (b *Bridge) NotifyWalletClosingPeriodElapsedGasEstimate( arg_walletPubKeyHash [20]byte, - arg_redeemerOutputScript []byte, ) (uint64, error) { var result uint64 result, err := chainutil.EstimateGas( b.callerOptions.From, b.contractAddress, - "notifyRedemptionVeto", + "notifyWalletClosingPeriodElapsed", b.contractABI, b.transactor, arg_walletPubKeyHash, - arg_redeemerOutputScript, ) return result, err } // Transaction submission. -func (b *Bridge) NotifyWalletCloseable( - arg_walletPubKeyHash [20]byte, - arg_walletMainUtxo abi.BitcoinTxUTXO, +func (b *Bridge) ReceiveBalanceApproval( + arg_balanceOwner common.Address, + arg_amount *big.Int, + arg_redemptionData []byte, transactionOptions ...chainutil.TransactionOptions, ) (*types.Transaction, error) { bLogger.Debug( - "submitting transaction notifyWalletCloseable", + "submitting transaction receiveBalanceApproval", " params: ", fmt.Sprint( - arg_walletPubKeyHash, - arg_walletMainUtxo, + arg_balanceOwner, + arg_amount, + arg_redemptionData, ), ) @@ -1994,24 +1946,26 @@ func (b *Bridge) NotifyWalletCloseable( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := b.contract.NotifyWalletCloseable( + transaction, err := b.contract.ReceiveBalanceApproval( transactorOptions, - arg_walletPubKeyHash, - arg_walletMainUtxo, + arg_balanceOwner, + arg_amount, + arg_redemptionData, ) if err != nil { return transaction, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "notifyWalletCloseable", - arg_walletPubKeyHash, - arg_walletMainUtxo, + "receiveBalanceApproval", + arg_balanceOwner, + arg_amount, + arg_redemptionData, ) } bLogger.Infof( - "submitted transaction notifyWalletCloseable with id: [%s] and nonce [%v]", + "submitted transaction receiveBalanceApproval with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -2030,24 +1984,26 @@ func (b *Bridge) NotifyWalletCloseable( newTransactorOptions.GasLimit = transactorOptions.GasLimit } - transaction, err := b.contract.NotifyWalletCloseable( + transaction, err := b.contract.ReceiveBalanceApproval( newTransactorOptions, - arg_walletPubKeyHash, - arg_walletMainUtxo, + arg_balanceOwner, + arg_amount, + arg_redemptionData, ) if err != nil { return nil, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "notifyWalletCloseable", - arg_walletPubKeyHash, - arg_walletMainUtxo, + "receiveBalanceApproval", + arg_balanceOwner, + arg_amount, + arg_redemptionData, ) } bLogger.Infof( - "submitted transaction notifyWalletCloseable with id: [%s] and nonce [%v]", + "submitted transaction receiveBalanceApproval with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -2062,9 +2018,10 @@ func (b *Bridge) NotifyWalletCloseable( } // Non-mutating call, not a transaction submission. -func (b *Bridge) CallNotifyWalletCloseable( - arg_walletPubKeyHash [20]byte, - arg_walletMainUtxo abi.BitcoinTxUTXO, +func (b *Bridge) CallReceiveBalanceApproval( + arg_balanceOwner common.Address, + arg_amount *big.Int, + arg_redemptionData []byte, blockNumber *big.Int, ) error { var result interface{} = nil @@ -2076,45 +2033,48 @@ func (b *Bridge) CallNotifyWalletCloseable( b.caller, b.errorResolver, b.contractAddress, - "notifyWalletCloseable", + "receiveBalanceApproval", &result, - arg_walletPubKeyHash, - arg_walletMainUtxo, + arg_balanceOwner, + arg_amount, + arg_redemptionData, ) return err } -func (b *Bridge) NotifyWalletCloseableGasEstimate( - arg_walletPubKeyHash [20]byte, - arg_walletMainUtxo abi.BitcoinTxUTXO, +func (b *Bridge) ReceiveBalanceApprovalGasEstimate( + arg_balanceOwner common.Address, + arg_amount *big.Int, + arg_redemptionData []byte, ) (uint64, error) { var result uint64 result, err := chainutil.EstimateGas( b.callerOptions.From, b.contractAddress, - "notifyWalletCloseable", + "receiveBalanceApproval", b.contractABI, b.transactor, - arg_walletPubKeyHash, - arg_walletMainUtxo, + arg_balanceOwner, + arg_amount, + arg_redemptionData, ) return result, err } // Transaction submission. -func (b *Bridge) NotifyWalletClosingPeriodElapsed( - arg_walletPubKeyHash [20]byte, +func (b *Bridge) RequestNewWallet( + arg_activeWalletMainUtxo abi.BitcoinTxUTXO, transactionOptions ...chainutil.TransactionOptions, ) (*types.Transaction, error) { bLogger.Debug( - "submitting transaction notifyWalletClosingPeriodElapsed", + "submitting transaction requestNewWallet", " params: ", fmt.Sprint( - arg_walletPubKeyHash, + arg_activeWalletMainUtxo, ), ) @@ -2140,22 +2100,22 @@ func (b *Bridge) NotifyWalletClosingPeriodElapsed( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := b.contract.NotifyWalletClosingPeriodElapsed( + transaction, err := b.contract.RequestNewWallet( transactorOptions, - arg_walletPubKeyHash, + arg_activeWalletMainUtxo, ) if err != nil { return transaction, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "notifyWalletClosingPeriodElapsed", - arg_walletPubKeyHash, + "requestNewWallet", + arg_activeWalletMainUtxo, ) } bLogger.Infof( - "submitted transaction notifyWalletClosingPeriodElapsed with id: [%s] and nonce [%v]", + "submitted transaction requestNewWallet with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -2174,22 +2134,22 @@ func (b *Bridge) NotifyWalletClosingPeriodElapsed( newTransactorOptions.GasLimit = transactorOptions.GasLimit } - transaction, err := b.contract.NotifyWalletClosingPeriodElapsed( + transaction, err := b.contract.RequestNewWallet( newTransactorOptions, - arg_walletPubKeyHash, + arg_activeWalletMainUtxo, ) if err != nil { return nil, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "notifyWalletClosingPeriodElapsed", - arg_walletPubKeyHash, + "requestNewWallet", + arg_activeWalletMainUtxo, ) } bLogger.Infof( - "submitted transaction notifyWalletClosingPeriodElapsed with id: [%s] and nonce [%v]", + "submitted transaction requestNewWallet with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -2204,8 +2164,8 @@ func (b *Bridge) NotifyWalletClosingPeriodElapsed( } // Non-mutating call, not a transaction submission. -func (b *Bridge) CallNotifyWalletClosingPeriodElapsed( - arg_walletPubKeyHash [20]byte, +func (b *Bridge) CallRequestNewWallet( + arg_activeWalletMainUtxo abi.BitcoinTxUTXO, blockNumber *big.Int, ) error { var result interface{} = nil @@ -2217,46 +2177,48 @@ func (b *Bridge) CallNotifyWalletClosingPeriodElapsed( b.caller, b.errorResolver, b.contractAddress, - "notifyWalletClosingPeriodElapsed", + "requestNewWallet", &result, - arg_walletPubKeyHash, + arg_activeWalletMainUtxo, ) return err } -func (b *Bridge) NotifyWalletClosingPeriodElapsedGasEstimate( - arg_walletPubKeyHash [20]byte, +func (b *Bridge) RequestNewWalletGasEstimate( + arg_activeWalletMainUtxo abi.BitcoinTxUTXO, ) (uint64, error) { var result uint64 result, err := chainutil.EstimateGas( b.callerOptions.From, b.contractAddress, - "notifyWalletClosingPeriodElapsed", + "requestNewWallet", b.contractABI, b.transactor, - arg_walletPubKeyHash, + arg_activeWalletMainUtxo, ) return result, err } // Transaction submission. -func (b *Bridge) ReceiveBalanceApproval( - arg_balanceOwner common.Address, - arg_amount *big.Int, - arg_redemptionData []byte, +func (b *Bridge) RequestRedemption( + arg_walletPubKeyHash [20]byte, + arg_mainUtxo abi.BitcoinTxUTXO, + arg_redeemerOutputScript []byte, + arg_amount uint64, transactionOptions ...chainutil.TransactionOptions, ) (*types.Transaction, error) { bLogger.Debug( - "submitting transaction receiveBalanceApproval", + "submitting transaction requestRedemption", " params: ", fmt.Sprint( - arg_balanceOwner, + arg_walletPubKeyHash, + arg_mainUtxo, + arg_redeemerOutputScript, arg_amount, - arg_redemptionData, ), ) @@ -2282,26 +2244,28 @@ func (b *Bridge) ReceiveBalanceApproval( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := b.contract.ReceiveBalanceApproval( + transaction, err := b.contract.RequestRedemption( transactorOptions, - arg_balanceOwner, + arg_walletPubKeyHash, + arg_mainUtxo, + arg_redeemerOutputScript, arg_amount, - arg_redemptionData, ) if err != nil { return transaction, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "receiveBalanceApproval", - arg_balanceOwner, + "requestRedemption", + arg_walletPubKeyHash, + arg_mainUtxo, + arg_redeemerOutputScript, arg_amount, - arg_redemptionData, ) } bLogger.Infof( - "submitted transaction receiveBalanceApproval with id: [%s] and nonce [%v]", + "submitted transaction requestRedemption with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -2320,26 +2284,28 @@ func (b *Bridge) ReceiveBalanceApproval( newTransactorOptions.GasLimit = transactorOptions.GasLimit } - transaction, err := b.contract.ReceiveBalanceApproval( + transaction, err := b.contract.RequestRedemption( newTransactorOptions, - arg_balanceOwner, + arg_walletPubKeyHash, + arg_mainUtxo, + arg_redeemerOutputScript, arg_amount, - arg_redemptionData, ) if err != nil { return nil, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "receiveBalanceApproval", - arg_balanceOwner, + "requestRedemption", + arg_walletPubKeyHash, + arg_mainUtxo, + arg_redeemerOutputScript, arg_amount, - arg_redemptionData, ) } bLogger.Infof( - "submitted transaction receiveBalanceApproval with id: [%s] and nonce [%v]", + "submitted transaction requestRedemption with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -2354,10 +2320,11 @@ func (b *Bridge) ReceiveBalanceApproval( } // Non-mutating call, not a transaction submission. -func (b *Bridge) CallReceiveBalanceApproval( - arg_balanceOwner common.Address, - arg_amount *big.Int, - arg_redemptionData []byte, +func (b *Bridge) CallRequestRedemption( + arg_walletPubKeyHash [20]byte, + arg_mainUtxo abi.BitcoinTxUTXO, + arg_redeemerOutputScript []byte, + arg_amount uint64, blockNumber *big.Int, ) error { var result interface{} = nil @@ -2369,48 +2336,51 @@ func (b *Bridge) CallReceiveBalanceApproval( b.caller, b.errorResolver, b.contractAddress, - "receiveBalanceApproval", + "requestRedemption", &result, - arg_balanceOwner, + arg_walletPubKeyHash, + arg_mainUtxo, + arg_redeemerOutputScript, arg_amount, - arg_redemptionData, ) return err } -func (b *Bridge) ReceiveBalanceApprovalGasEstimate( - arg_balanceOwner common.Address, - arg_amount *big.Int, - arg_redemptionData []byte, +func (b *Bridge) RequestRedemptionGasEstimate( + arg_walletPubKeyHash [20]byte, + arg_mainUtxo abi.BitcoinTxUTXO, + arg_redeemerOutputScript []byte, + arg_amount uint64, ) (uint64, error) { var result uint64 result, err := chainutil.EstimateGas( b.callerOptions.From, b.contractAddress, - "receiveBalanceApproval", + "requestRedemption", b.contractABI, b.transactor, - arg_balanceOwner, + arg_walletPubKeyHash, + arg_mainUtxo, + arg_redeemerOutputScript, arg_amount, - arg_redemptionData, ) return result, err } // Transaction submission. -func (b *Bridge) RequestNewWallet( - arg_activeWalletMainUtxo abi.BitcoinTxUTXO, +func (b *Bridge) ResetMovingFundsTimeout( + arg_walletPubKeyHash [20]byte, transactionOptions ...chainutil.TransactionOptions, ) (*types.Transaction, error) { bLogger.Debug( - "submitting transaction requestNewWallet", + "submitting transaction resetMovingFundsTimeout", " params: ", fmt.Sprint( - arg_activeWalletMainUtxo, + arg_walletPubKeyHash, ), ) @@ -2436,22 +2406,22 @@ func (b *Bridge) RequestNewWallet( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := b.contract.RequestNewWallet( + transaction, err := b.contract.ResetMovingFundsTimeout( transactorOptions, - arg_activeWalletMainUtxo, + arg_walletPubKeyHash, ) if err != nil { return transaction, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "requestNewWallet", - arg_activeWalletMainUtxo, + "resetMovingFundsTimeout", + arg_walletPubKeyHash, ) } bLogger.Infof( - "submitted transaction requestNewWallet with id: [%s] and nonce [%v]", + "submitted transaction resetMovingFundsTimeout with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -2470,22 +2440,22 @@ func (b *Bridge) RequestNewWallet( newTransactorOptions.GasLimit = transactorOptions.GasLimit } - transaction, err := b.contract.RequestNewWallet( + transaction, err := b.contract.ResetMovingFundsTimeout( newTransactorOptions, - arg_activeWalletMainUtxo, + arg_walletPubKeyHash, ) if err != nil { return nil, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "requestNewWallet", - arg_activeWalletMainUtxo, + "resetMovingFundsTimeout", + arg_walletPubKeyHash, ) } bLogger.Infof( - "submitted transaction requestNewWallet with id: [%s] and nonce [%v]", + "submitted transaction resetMovingFundsTimeout with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -2500,8 +2470,8 @@ func (b *Bridge) RequestNewWallet( } // Non-mutating call, not a transaction submission. -func (b *Bridge) CallRequestNewWallet( - arg_activeWalletMainUtxo abi.BitcoinTxUTXO, +func (b *Bridge) CallResetMovingFundsTimeout( + arg_walletPubKeyHash [20]byte, blockNumber *big.Int, ) error { var result interface{} = nil @@ -2513,49 +2483,38 @@ func (b *Bridge) CallRequestNewWallet( b.caller, b.errorResolver, b.contractAddress, - "requestNewWallet", + "resetMovingFundsTimeout", &result, - arg_activeWalletMainUtxo, + arg_walletPubKeyHash, ) return err } -func (b *Bridge) RequestNewWalletGasEstimate( - arg_activeWalletMainUtxo abi.BitcoinTxUTXO, +func (b *Bridge) ResetMovingFundsTimeoutGasEstimate( + arg_walletPubKeyHash [20]byte, ) (uint64, error) { var result uint64 result, err := chainutil.EstimateGas( b.callerOptions.From, b.contractAddress, - "requestNewWallet", + "resetMovingFundsTimeout", b.contractABI, b.transactor, - arg_activeWalletMainUtxo, + arg_walletPubKeyHash, ) return result, err } // Transaction submission. -func (b *Bridge) RequestRedemption( - arg_walletPubKeyHash [20]byte, - arg_mainUtxo abi.BitcoinTxUTXO, - arg_redeemerOutputScript []byte, - arg_amount uint64, +func (b *Bridge) RetireEcdsa( transactionOptions ...chainutil.TransactionOptions, ) (*types.Transaction, error) { bLogger.Debug( - "submitting transaction requestRedemption", - " params: ", - fmt.Sprint( - arg_walletPubKeyHash, - arg_mainUtxo, - arg_redeemerOutputScript, - arg_amount, - ), + "submitting transaction retireEcdsa", ) b.transactionMutex.Lock() @@ -2580,28 +2539,20 @@ func (b *Bridge) RequestRedemption( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := b.contract.RequestRedemption( + transaction, err := b.contract.RetireEcdsa( transactorOptions, - arg_walletPubKeyHash, - arg_mainUtxo, - arg_redeemerOutputScript, - arg_amount, ) if err != nil { return transaction, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "requestRedemption", - arg_walletPubKeyHash, - arg_mainUtxo, - arg_redeemerOutputScript, - arg_amount, + "retireEcdsa", ) } bLogger.Infof( - "submitted transaction requestRedemption with id: [%s] and nonce [%v]", + "submitted transaction retireEcdsa with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -2620,28 +2571,20 @@ func (b *Bridge) RequestRedemption( newTransactorOptions.GasLimit = transactorOptions.GasLimit } - transaction, err := b.contract.RequestRedemption( + transaction, err := b.contract.RetireEcdsa( newTransactorOptions, - arg_walletPubKeyHash, - arg_mainUtxo, - arg_redeemerOutputScript, - arg_amount, ) if err != nil { return nil, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "requestRedemption", - arg_walletPubKeyHash, - arg_mainUtxo, - arg_redeemerOutputScript, - arg_amount, + "retireEcdsa", ) } bLogger.Infof( - "submitted transaction requestRedemption with id: [%s] and nonce [%v]", + "submitted transaction retireEcdsa with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -2656,11 +2599,7 @@ func (b *Bridge) RequestRedemption( } // Non-mutating call, not a transaction submission. -func (b *Bridge) CallRequestRedemption( - arg_walletPubKeyHash [20]byte, - arg_mainUtxo abi.BitcoinTxUTXO, - arg_redeemerOutputScript []byte, - arg_amount uint64, +func (b *Bridge) CallRetireEcdsa( blockNumber *big.Int, ) error { var result interface{} = nil @@ -2672,51 +2611,40 @@ func (b *Bridge) CallRequestRedemption( b.caller, b.errorResolver, b.contractAddress, - "requestRedemption", + "retireEcdsa", &result, - arg_walletPubKeyHash, - arg_mainUtxo, - arg_redeemerOutputScript, - arg_amount, ) return err } -func (b *Bridge) RequestRedemptionGasEstimate( - arg_walletPubKeyHash [20]byte, - arg_mainUtxo abi.BitcoinTxUTXO, - arg_redeemerOutputScript []byte, - arg_amount uint64, -) (uint64, error) { +func (b *Bridge) RetireEcdsaGasEstimate() (uint64, error) { var result uint64 result, err := chainutil.EstimateGas( b.callerOptions.From, b.contractAddress, - "requestRedemption", + "retireEcdsa", b.contractABI, b.transactor, - arg_walletPubKeyHash, - arg_mainUtxo, - arg_redeemerOutputScript, - arg_amount, ) return result, err } // Transaction submission. -func (b *Bridge) ResetMovingFundsTimeout( - arg_walletPubKeyHash [20]byte, +func (b *Bridge) RevealDeposit( + arg_fundingTx abi.BitcoinTxInfo, + arg_reveal abi.DepositDepositRevealInfo, transactionOptions ...chainutil.TransactionOptions, ) (*types.Transaction, error) { bLogger.Debug( - "submitting transaction resetMovingFundsTimeout", + "submitting transaction revealDeposit", " params: ", fmt.Sprint( - arg_walletPubKeyHash, + arg_fundingTx, + arg_reveal, ), ) @@ -2742,22 +2670,24 @@ func (b *Bridge) ResetMovingFundsTimeout( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := b.contract.ResetMovingFundsTimeout( + transaction, err := b.contract.RevealDeposit( transactorOptions, - arg_walletPubKeyHash, + arg_fundingTx, + arg_reveal, ) if err != nil { return transaction, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "resetMovingFundsTimeout", - arg_walletPubKeyHash, + "revealDeposit", + arg_fundingTx, + arg_reveal, ) } bLogger.Infof( - "submitted transaction resetMovingFundsTimeout with id: [%s] and nonce [%v]", + "submitted transaction revealDeposit with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -2776,22 +2706,24 @@ func (b *Bridge) ResetMovingFundsTimeout( newTransactorOptions.GasLimit = transactorOptions.GasLimit } - transaction, err := b.contract.ResetMovingFundsTimeout( + transaction, err := b.contract.RevealDeposit( newTransactorOptions, - arg_walletPubKeyHash, + arg_fundingTx, + arg_reveal, ) if err != nil { return nil, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "resetMovingFundsTimeout", - arg_walletPubKeyHash, + "revealDeposit", + arg_fundingTx, + arg_reveal, ) } bLogger.Infof( - "submitted transaction resetMovingFundsTimeout with id: [%s] and nonce [%v]", + "submitted transaction revealDeposit with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -2806,8 +2738,9 @@ func (b *Bridge) ResetMovingFundsTimeout( } // Non-mutating call, not a transaction submission. -func (b *Bridge) CallResetMovingFundsTimeout( - arg_walletPubKeyHash [20]byte, +func (b *Bridge) CallRevealDeposit( + arg_fundingTx abi.BitcoinTxInfo, + arg_reveal abi.DepositDepositRevealInfo, blockNumber *big.Int, ) error { var result interface{} = nil @@ -2819,44 +2752,49 @@ func (b *Bridge) CallResetMovingFundsTimeout( b.caller, b.errorResolver, b.contractAddress, - "resetMovingFundsTimeout", + "revealDeposit", &result, - arg_walletPubKeyHash, + arg_fundingTx, + arg_reveal, ) return err } -func (b *Bridge) ResetMovingFundsTimeoutGasEstimate( - arg_walletPubKeyHash [20]byte, +func (b *Bridge) RevealDepositGasEstimate( + arg_fundingTx abi.BitcoinTxInfo, + arg_reveal abi.DepositDepositRevealInfo, ) (uint64, error) { var result uint64 result, err := chainutil.EstimateGas( b.callerOptions.From, b.contractAddress, - "resetMovingFundsTimeout", + "revealDeposit", b.contractABI, b.transactor, - arg_walletPubKeyHash, + arg_fundingTx, + arg_reveal, ) return result, err } // Transaction submission. -func (b *Bridge) RevealDeposit( +func (b *Bridge) RevealDepositWithExtraData( arg_fundingTx abi.BitcoinTxInfo, arg_reveal abi.DepositDepositRevealInfo, + arg_extraData [32]byte, transactionOptions ...chainutil.TransactionOptions, ) (*types.Transaction, error) { bLogger.Debug( - "submitting transaction revealDeposit", + "submitting transaction revealDepositWithExtraData", " params: ", fmt.Sprint( arg_fundingTx, arg_reveal, + arg_extraData, ), ) @@ -2882,24 +2820,26 @@ func (b *Bridge) RevealDeposit( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := b.contract.RevealDeposit( + transaction, err := b.contract.RevealDepositWithExtraData( transactorOptions, arg_fundingTx, arg_reveal, + arg_extraData, ) if err != nil { return transaction, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "revealDeposit", + "revealDepositWithExtraData", arg_fundingTx, arg_reveal, + arg_extraData, ) } bLogger.Infof( - "submitted transaction revealDeposit with id: [%s] and nonce [%v]", + "submitted transaction revealDepositWithExtraData with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -2918,24 +2858,26 @@ func (b *Bridge) RevealDeposit( newTransactorOptions.GasLimit = transactorOptions.GasLimit } - transaction, err := b.contract.RevealDeposit( + transaction, err := b.contract.RevealDepositWithExtraData( newTransactorOptions, arg_fundingTx, arg_reveal, + arg_extraData, ) if err != nil { return nil, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "revealDeposit", + "revealDepositWithExtraData", arg_fundingTx, arg_reveal, + arg_extraData, ) } bLogger.Infof( - "submitted transaction revealDeposit with id: [%s] and nonce [%v]", + "submitted transaction revealDepositWithExtraData with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -2950,9 +2892,10 @@ func (b *Bridge) RevealDeposit( } // Non-mutating call, not a transaction submission. -func (b *Bridge) CallRevealDeposit( +func (b *Bridge) CallRevealDepositWithExtraData( arg_fundingTx abi.BitcoinTxInfo, arg_reveal abi.DepositDepositRevealInfo, + arg_extraData [32]byte, blockNumber *big.Int, ) error { var result interface{} = nil @@ -2964,49 +2907,50 @@ func (b *Bridge) CallRevealDeposit( b.caller, b.errorResolver, b.contractAddress, - "revealDeposit", + "revealDepositWithExtraData", &result, arg_fundingTx, arg_reveal, + arg_extraData, ) return err } -func (b *Bridge) RevealDepositGasEstimate( +func (b *Bridge) RevealDepositWithExtraDataGasEstimate( arg_fundingTx abi.BitcoinTxInfo, arg_reveal abi.DepositDepositRevealInfo, + arg_extraData [32]byte, ) (uint64, error) { var result uint64 result, err := chainutil.EstimateGas( b.callerOptions.From, b.contractAddress, - "revealDeposit", + "revealDepositWithExtraData", b.contractABI, b.transactor, arg_fundingTx, arg_reveal, + arg_extraData, ) return result, err } // Transaction submission. -func (b *Bridge) RevealDepositWithExtraData( +func (b *Bridge) RevealTaprootDeposit( arg_fundingTx abi.BitcoinTxInfo, - arg_reveal abi.DepositDepositRevealInfo, - arg_extraData [32]byte, + arg_reveal abi.DepositTaprootDepositRevealInfo, transactionOptions ...chainutil.TransactionOptions, ) (*types.Transaction, error) { bLogger.Debug( - "submitting transaction revealDepositWithExtraData", + "submitting transaction revealTaprootDeposit", " params: ", fmt.Sprint( arg_fundingTx, arg_reveal, - arg_extraData, ), ) @@ -3032,26 +2976,24 @@ func (b *Bridge) RevealDepositWithExtraData( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := b.contract.RevealDepositWithExtraData( + transaction, err := b.contract.RevealTaprootDeposit( transactorOptions, arg_fundingTx, arg_reveal, - arg_extraData, ) if err != nil { return transaction, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "revealDepositWithExtraData", + "revealTaprootDeposit", arg_fundingTx, arg_reveal, - arg_extraData, ) } bLogger.Infof( - "submitted transaction revealDepositWithExtraData with id: [%s] and nonce [%v]", + "submitted transaction revealTaprootDeposit with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -3070,26 +3012,24 @@ func (b *Bridge) RevealDepositWithExtraData( newTransactorOptions.GasLimit = transactorOptions.GasLimit } - transaction, err := b.contract.RevealDepositWithExtraData( + transaction, err := b.contract.RevealTaprootDeposit( newTransactorOptions, arg_fundingTx, arg_reveal, - arg_extraData, ) if err != nil { return nil, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "revealDepositWithExtraData", + "revealTaprootDeposit", arg_fundingTx, arg_reveal, - arg_extraData, ) } bLogger.Infof( - "submitted transaction revealDepositWithExtraData with id: [%s] and nonce [%v]", + "submitted transaction revealTaprootDeposit with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -3104,10 +3044,9 @@ func (b *Bridge) RevealDepositWithExtraData( } // Non-mutating call, not a transaction submission. -func (b *Bridge) CallRevealDepositWithExtraData( +func (b *Bridge) CallRevealTaprootDeposit( arg_fundingTx abi.BitcoinTxInfo, - arg_reveal abi.DepositDepositRevealInfo, - arg_extraData [32]byte, + arg_reveal abi.DepositTaprootDepositRevealInfo, blockNumber *big.Int, ) error { var result interface{} = nil @@ -3119,48 +3058,49 @@ func (b *Bridge) CallRevealDepositWithExtraData( b.caller, b.errorResolver, b.contractAddress, - "revealDepositWithExtraData", + "revealTaprootDeposit", &result, arg_fundingTx, arg_reveal, - arg_extraData, ) return err } -func (b *Bridge) RevealDepositWithExtraDataGasEstimate( +func (b *Bridge) RevealTaprootDepositGasEstimate( arg_fundingTx abi.BitcoinTxInfo, - arg_reveal abi.DepositDepositRevealInfo, - arg_extraData [32]byte, + arg_reveal abi.DepositTaprootDepositRevealInfo, ) (uint64, error) { var result uint64 result, err := chainutil.EstimateGas( b.callerOptions.From, b.contractAddress, - "revealDepositWithExtraData", + "revealTaprootDeposit", b.contractABI, b.transactor, arg_fundingTx, arg_reveal, - arg_extraData, ) return result, err } // Transaction submission. -func (b *Bridge) SetRebateStaking( - arg_rebateStaking common.Address, +func (b *Bridge) RevealTaprootDepositWithExtraData( + arg_fundingTx abi.BitcoinTxInfo, + arg_reveal abi.DepositTaprootDepositRevealInfo, + arg_extraData [32]byte, transactionOptions ...chainutil.TransactionOptions, ) (*types.Transaction, error) { bLogger.Debug( - "submitting transaction setRebateStaking", + "submitting transaction revealTaprootDepositWithExtraData", " params: ", fmt.Sprint( - arg_rebateStaking, + arg_fundingTx, + arg_reveal, + arg_extraData, ), ) @@ -3186,22 +3126,26 @@ func (b *Bridge) SetRebateStaking( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := b.contract.SetRebateStaking( + transaction, err := b.contract.RevealTaprootDepositWithExtraData( transactorOptions, - arg_rebateStaking, + arg_fundingTx, + arg_reveal, + arg_extraData, ) if err != nil { return transaction, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "setRebateStaking", - arg_rebateStaking, + "revealTaprootDepositWithExtraData", + arg_fundingTx, + arg_reveal, + arg_extraData, ) } bLogger.Infof( - "submitted transaction setRebateStaking with id: [%s] and nonce [%v]", + "submitted transaction revealTaprootDepositWithExtraData with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -3220,22 +3164,26 @@ func (b *Bridge) SetRebateStaking( newTransactorOptions.GasLimit = transactorOptions.GasLimit } - transaction, err := b.contract.SetRebateStaking( + transaction, err := b.contract.RevealTaprootDepositWithExtraData( newTransactorOptions, - arg_rebateStaking, + arg_fundingTx, + arg_reveal, + arg_extraData, ) if err != nil { return nil, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "setRebateStaking", - arg_rebateStaking, + "revealTaprootDepositWithExtraData", + arg_fundingTx, + arg_reveal, + arg_extraData, ) } bLogger.Infof( - "submitted transaction setRebateStaking with id: [%s] and nonce [%v]", + "submitted transaction revealTaprootDepositWithExtraData with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -3250,8 +3198,10 @@ func (b *Bridge) SetRebateStaking( } // Non-mutating call, not a transaction submission. -func (b *Bridge) CallSetRebateStaking( - arg_rebateStaking common.Address, +func (b *Bridge) CallRevealTaprootDepositWithExtraData( + arg_fundingTx abi.BitcoinTxInfo, + arg_reveal abi.DepositTaprootDepositRevealInfo, + arg_extraData [32]byte, blockNumber *big.Int, ) error { var result interface{} = nil @@ -3263,42 +3213,48 @@ func (b *Bridge) CallSetRebateStaking( b.caller, b.errorResolver, b.contractAddress, - "setRebateStaking", + "revealTaprootDepositWithExtraData", &result, - arg_rebateStaking, + arg_fundingTx, + arg_reveal, + arg_extraData, ) return err } -func (b *Bridge) SetRebateStakingGasEstimate( - arg_rebateStaking common.Address, +func (b *Bridge) RevealTaprootDepositWithExtraDataGasEstimate( + arg_fundingTx abi.BitcoinTxInfo, + arg_reveal abi.DepositTaprootDepositRevealInfo, + arg_extraData [32]byte, ) (uint64, error) { var result uint64 result, err := chainutil.EstimateGas( b.callerOptions.From, b.contractAddress, - "setRebateStaking", + "revealTaprootDepositWithExtraData", b.contractABI, b.transactor, - arg_rebateStaking, + arg_fundingTx, + arg_reveal, + arg_extraData, ) return result, err } // Transaction submission. -func (b *Bridge) SetRedemptionWatchtower( - arg_redemptionWatchtower common.Address, +func (b *Bridge) SetEcdsaFraudRouter( + arg_ecdsaFraudRouter common.Address, transactionOptions ...chainutil.TransactionOptions, ) (*types.Transaction, error) { bLogger.Debug( - "submitting transaction setRedemptionWatchtower", + "submitting transaction setEcdsaFraudRouter", " params: ", fmt.Sprint( - arg_redemptionWatchtower, + arg_ecdsaFraudRouter, ), ) @@ -3324,22 +3280,22 @@ func (b *Bridge) SetRedemptionWatchtower( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := b.contract.SetRedemptionWatchtower( + transaction, err := b.contract.SetEcdsaFraudRouter( transactorOptions, - arg_redemptionWatchtower, + arg_ecdsaFraudRouter, ) if err != nil { return transaction, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "setRedemptionWatchtower", - arg_redemptionWatchtower, + "setEcdsaFraudRouter", + arg_ecdsaFraudRouter, ) } bLogger.Infof( - "submitted transaction setRedemptionWatchtower with id: [%s] and nonce [%v]", + "submitted transaction setEcdsaFraudRouter with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -3358,22 +3314,22 @@ func (b *Bridge) SetRedemptionWatchtower( newTransactorOptions.GasLimit = transactorOptions.GasLimit } - transaction, err := b.contract.SetRedemptionWatchtower( + transaction, err := b.contract.SetEcdsaFraudRouter( newTransactorOptions, - arg_redemptionWatchtower, + arg_ecdsaFraudRouter, ) if err != nil { return nil, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "setRedemptionWatchtower", - arg_redemptionWatchtower, + "setEcdsaFraudRouter", + arg_ecdsaFraudRouter, ) } bLogger.Infof( - "submitted transaction setRedemptionWatchtower with id: [%s] and nonce [%v]", + "submitted transaction setEcdsaFraudRouter with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -3388,8 +3344,8 @@ func (b *Bridge) SetRedemptionWatchtower( } // Non-mutating call, not a transaction submission. -func (b *Bridge) CallSetRedemptionWatchtower( - arg_redemptionWatchtower common.Address, +func (b *Bridge) CallSetEcdsaFraudRouter( + arg_ecdsaFraudRouter common.Address, blockNumber *big.Int, ) error { var result interface{} = nil @@ -3401,44 +3357,42 @@ func (b *Bridge) CallSetRedemptionWatchtower( b.caller, b.errorResolver, b.contractAddress, - "setRedemptionWatchtower", + "setEcdsaFraudRouter", &result, - arg_redemptionWatchtower, + arg_ecdsaFraudRouter, ) return err } -func (b *Bridge) SetRedemptionWatchtowerGasEstimate( - arg_redemptionWatchtower common.Address, +func (b *Bridge) SetEcdsaFraudRouterGasEstimate( + arg_ecdsaFraudRouter common.Address, ) (uint64, error) { var result uint64 result, err := chainutil.EstimateGas( b.callerOptions.From, b.contractAddress, - "setRedemptionWatchtower", + "setEcdsaFraudRouter", b.contractABI, b.transactor, - arg_redemptionWatchtower, + arg_ecdsaFraudRouter, ) return result, err } // Transaction submission. -func (b *Bridge) SetSpvMaintainerStatus( - arg_spvMaintainer common.Address, - arg_isTrusted bool, +func (b *Bridge) SetFrostWalletRegistry( + arg_frostWalletRegistry common.Address, transactionOptions ...chainutil.TransactionOptions, ) (*types.Transaction, error) { bLogger.Debug( - "submitting transaction setSpvMaintainerStatus", + "submitting transaction setFrostWalletRegistry", " params: ", fmt.Sprint( - arg_spvMaintainer, - arg_isTrusted, + arg_frostWalletRegistry, ), ) @@ -3464,24 +3418,22 @@ func (b *Bridge) SetSpvMaintainerStatus( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := b.contract.SetSpvMaintainerStatus( + transaction, err := b.contract.SetFrostWalletRegistry( transactorOptions, - arg_spvMaintainer, - arg_isTrusted, + arg_frostWalletRegistry, ) if err != nil { return transaction, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "setSpvMaintainerStatus", - arg_spvMaintainer, - arg_isTrusted, + "setFrostWalletRegistry", + arg_frostWalletRegistry, ) } bLogger.Infof( - "submitted transaction setSpvMaintainerStatus with id: [%s] and nonce [%v]", + "submitted transaction setFrostWalletRegistry with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -3500,24 +3452,22 @@ func (b *Bridge) SetSpvMaintainerStatus( newTransactorOptions.GasLimit = transactorOptions.GasLimit } - transaction, err := b.contract.SetSpvMaintainerStatus( + transaction, err := b.contract.SetFrostWalletRegistry( newTransactorOptions, - arg_spvMaintainer, - arg_isTrusted, + arg_frostWalletRegistry, ) if err != nil { return nil, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "setSpvMaintainerStatus", - arg_spvMaintainer, - arg_isTrusted, + "setFrostWalletRegistry", + arg_frostWalletRegistry, ) } bLogger.Infof( - "submitted transaction setSpvMaintainerStatus with id: [%s] and nonce [%v]", + "submitted transaction setFrostWalletRegistry with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -3532,9 +3482,8 @@ func (b *Bridge) SetSpvMaintainerStatus( } // Non-mutating call, not a transaction submission. -func (b *Bridge) CallSetSpvMaintainerStatus( - arg_spvMaintainer common.Address, - arg_isTrusted bool, +func (b *Bridge) CallSetFrostWalletRegistry( + arg_frostWalletRegistry common.Address, blockNumber *big.Int, ) error { var result interface{} = nil @@ -3546,47 +3495,42 @@ func (b *Bridge) CallSetSpvMaintainerStatus( b.caller, b.errorResolver, b.contractAddress, - "setSpvMaintainerStatus", + "setFrostWalletRegistry", &result, - arg_spvMaintainer, - arg_isTrusted, + arg_frostWalletRegistry, ) return err } -func (b *Bridge) SetSpvMaintainerStatusGasEstimate( - arg_spvMaintainer common.Address, - arg_isTrusted bool, +func (b *Bridge) SetFrostWalletRegistryGasEstimate( + arg_frostWalletRegistry common.Address, ) (uint64, error) { var result uint64 result, err := chainutil.EstimateGas( b.callerOptions.From, b.contractAddress, - "setSpvMaintainerStatus", + "setFrostWalletRegistry", b.contractABI, b.transactor, - arg_spvMaintainer, - arg_isTrusted, + arg_frostWalletRegistry, ) return result, err } // Transaction submission. -func (b *Bridge) SetVaultStatus( - arg_vault common.Address, - arg_isTrusted bool, +func (b *Bridge) SetLifecycleRouter( + arg_lifecycleRouter common.Address, transactionOptions ...chainutil.TransactionOptions, ) (*types.Transaction, error) { bLogger.Debug( - "submitting transaction setVaultStatus", + "submitting transaction setLifecycleRouter", " params: ", fmt.Sprint( - arg_vault, - arg_isTrusted, + arg_lifecycleRouter, ), ) @@ -3612,24 +3556,22 @@ func (b *Bridge) SetVaultStatus( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := b.contract.SetVaultStatus( + transaction, err := b.contract.SetLifecycleRouter( transactorOptions, - arg_vault, - arg_isTrusted, + arg_lifecycleRouter, ) if err != nil { return transaction, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "setVaultStatus", - arg_vault, - arg_isTrusted, + "setLifecycleRouter", + arg_lifecycleRouter, ) } bLogger.Infof( - "submitted transaction setVaultStatus with id: [%s] and nonce [%v]", + "submitted transaction setLifecycleRouter with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -3648,24 +3590,22 @@ func (b *Bridge) SetVaultStatus( newTransactorOptions.GasLimit = transactorOptions.GasLimit } - transaction, err := b.contract.SetVaultStatus( + transaction, err := b.contract.SetLifecycleRouter( newTransactorOptions, - arg_vault, - arg_isTrusted, + arg_lifecycleRouter, ) if err != nil { return nil, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "setVaultStatus", - arg_vault, - arg_isTrusted, + "setLifecycleRouter", + arg_lifecycleRouter, ) } bLogger.Infof( - "submitted transaction setVaultStatus with id: [%s] and nonce [%v]", + "submitted transaction setLifecycleRouter with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -3680,9 +3620,8 @@ func (b *Bridge) SetVaultStatus( } // Non-mutating call, not a transaction submission. -func (b *Bridge) CallSetVaultStatus( - arg_vault common.Address, - arg_isTrusted bool, +func (b *Bridge) CallSetLifecycleRouter( + arg_lifecycleRouter common.Address, blockNumber *big.Int, ) error { var result interface{} = nil @@ -3694,51 +3633,42 @@ func (b *Bridge) CallSetVaultStatus( b.caller, b.errorResolver, b.contractAddress, - "setVaultStatus", + "setLifecycleRouter", &result, - arg_vault, - arg_isTrusted, + arg_lifecycleRouter, ) return err } -func (b *Bridge) SetVaultStatusGasEstimate( - arg_vault common.Address, - arg_isTrusted bool, +func (b *Bridge) SetLifecycleRouterGasEstimate( + arg_lifecycleRouter common.Address, ) (uint64, error) { var result uint64 result, err := chainutil.EstimateGas( b.callerOptions.From, b.contractAddress, - "setVaultStatus", + "setLifecycleRouter", b.contractABI, b.transactor, - arg_vault, - arg_isTrusted, + arg_lifecycleRouter, ) return result, err } // Transaction submission. -func (b *Bridge) SubmitDepositSweepProof( - arg_sweepTx abi.BitcoinTxInfo, - arg_sweepProof abi.BitcoinTxProof, - arg_mainUtxo abi.BitcoinTxUTXO, - arg_vault common.Address, +func (b *Bridge) SetP2TRFraudRouter( + arg_p2trFraudRouter common.Address, transactionOptions ...chainutil.TransactionOptions, ) (*types.Transaction, error) { bLogger.Debug( - "submitting transaction submitDepositSweepProof", + "submitting transaction setP2TRFraudRouter", " params: ", fmt.Sprint( - arg_sweepTx, - arg_sweepProof, - arg_mainUtxo, - arg_vault, + arg_p2trFraudRouter, ), ) @@ -3764,28 +3694,22 @@ func (b *Bridge) SubmitDepositSweepProof( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := b.contract.SubmitDepositSweepProof( + transaction, err := b.contract.SetP2TRFraudRouter( transactorOptions, - arg_sweepTx, - arg_sweepProof, - arg_mainUtxo, - arg_vault, + arg_p2trFraudRouter, ) if err != nil { return transaction, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "submitDepositSweepProof", - arg_sweepTx, - arg_sweepProof, - arg_mainUtxo, - arg_vault, + "setP2TRFraudRouter", + arg_p2trFraudRouter, ) } bLogger.Infof( - "submitted transaction submitDepositSweepProof with id: [%s] and nonce [%v]", + "submitted transaction setP2TRFraudRouter with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -3804,28 +3728,22 @@ func (b *Bridge) SubmitDepositSweepProof( newTransactorOptions.GasLimit = transactorOptions.GasLimit } - transaction, err := b.contract.SubmitDepositSweepProof( + transaction, err := b.contract.SetP2TRFraudRouter( newTransactorOptions, - arg_sweepTx, - arg_sweepProof, - arg_mainUtxo, - arg_vault, + arg_p2trFraudRouter, ) if err != nil { return nil, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "submitDepositSweepProof", - arg_sweepTx, - arg_sweepProof, - arg_mainUtxo, - arg_vault, + "setP2TRFraudRouter", + arg_p2trFraudRouter, ) } bLogger.Infof( - "submitted transaction submitDepositSweepProof with id: [%s] and nonce [%v]", + "submitted transaction setP2TRFraudRouter with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -3840,11 +3758,8 @@ func (b *Bridge) SubmitDepositSweepProof( } // Non-mutating call, not a transaction submission. -func (b *Bridge) CallSubmitDepositSweepProof( - arg_sweepTx abi.BitcoinTxInfo, - arg_sweepProof abi.BitcoinTxProof, - arg_mainUtxo abi.BitcoinTxUTXO, - arg_vault common.Address, +func (b *Bridge) CallSetP2TRFraudRouter( + arg_p2trFraudRouter common.Address, blockNumber *big.Int, ) error { var result interface{} = nil @@ -3856,55 +3771,42 @@ func (b *Bridge) CallSubmitDepositSweepProof( b.caller, b.errorResolver, b.contractAddress, - "submitDepositSweepProof", + "setP2TRFraudRouter", &result, - arg_sweepTx, - arg_sweepProof, - arg_mainUtxo, - arg_vault, + arg_p2trFraudRouter, ) return err } -func (b *Bridge) SubmitDepositSweepProofGasEstimate( - arg_sweepTx abi.BitcoinTxInfo, - arg_sweepProof abi.BitcoinTxProof, - arg_mainUtxo abi.BitcoinTxUTXO, - arg_vault common.Address, +func (b *Bridge) SetP2TRFraudRouterGasEstimate( + arg_p2trFraudRouter common.Address, ) (uint64, error) { var result uint64 result, err := chainutil.EstimateGas( b.callerOptions.From, b.contractAddress, - "submitDepositSweepProof", + "setP2TRFraudRouter", b.contractABI, b.transactor, - arg_sweepTx, - arg_sweepProof, - arg_mainUtxo, - arg_vault, + arg_p2trFraudRouter, ) return result, err } // Transaction submission. -func (b *Bridge) SubmitFraudChallenge( - arg_walletPublicKey []byte, - arg_preimageSha256 []byte, - arg_signature abi.BitcoinTxRSVSignature, +func (b *Bridge) SetRebateStaking( + arg_rebateStaking common.Address, transactionOptions ...chainutil.TransactionOptions, ) (*types.Transaction, error) { bLogger.Debug( - "submitting transaction submitFraudChallenge", + "submitting transaction setRebateStaking", " params: ", fmt.Sprint( - arg_walletPublicKey, - arg_preimageSha256, - arg_signature, + arg_rebateStaking, ), ) @@ -3930,26 +3832,22 @@ func (b *Bridge) SubmitFraudChallenge( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := b.contract.SubmitFraudChallenge( + transaction, err := b.contract.SetRebateStaking( transactorOptions, - arg_walletPublicKey, - arg_preimageSha256, - arg_signature, + arg_rebateStaking, ) if err != nil { return transaction, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "submitFraudChallenge", - arg_walletPublicKey, - arg_preimageSha256, - arg_signature, + "setRebateStaking", + arg_rebateStaking, ) } bLogger.Infof( - "submitted transaction submitFraudChallenge with id: [%s] and nonce [%v]", + "submitted transaction setRebateStaking with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -3968,26 +3866,22 @@ func (b *Bridge) SubmitFraudChallenge( newTransactorOptions.GasLimit = transactorOptions.GasLimit } - transaction, err := b.contract.SubmitFraudChallenge( + transaction, err := b.contract.SetRebateStaking( newTransactorOptions, - arg_walletPublicKey, - arg_preimageSha256, - arg_signature, + arg_rebateStaking, ) if err != nil { return nil, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "submitFraudChallenge", - arg_walletPublicKey, - arg_preimageSha256, - arg_signature, + "setRebateStaking", + arg_rebateStaking, ) } bLogger.Infof( - "submitted transaction submitFraudChallenge with id: [%s] and nonce [%v]", + "submitted transaction setRebateStaking with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -4002,10 +3896,8 @@ func (b *Bridge) SubmitFraudChallenge( } // Non-mutating call, not a transaction submission. -func (b *Bridge) CallSubmitFraudChallenge( - arg_walletPublicKey []byte, - arg_preimageSha256 []byte, - arg_signature abi.BitcoinTxRSVSignature, +func (b *Bridge) CallSetRebateStaking( + arg_rebateStaking common.Address, blockNumber *big.Int, ) error { var result interface{} = nil @@ -4017,52 +3909,42 @@ func (b *Bridge) CallSubmitFraudChallenge( b.caller, b.errorResolver, b.contractAddress, - "submitFraudChallenge", + "setRebateStaking", &result, - arg_walletPublicKey, - arg_preimageSha256, - arg_signature, + arg_rebateStaking, ) return err } -func (b *Bridge) SubmitFraudChallengeGasEstimate( - arg_walletPublicKey []byte, - arg_preimageSha256 []byte, - arg_signature abi.BitcoinTxRSVSignature, +func (b *Bridge) SetRebateStakingGasEstimate( + arg_rebateStaking common.Address, ) (uint64, error) { var result uint64 result, err := chainutil.EstimateGas( b.callerOptions.From, b.contractAddress, - "submitFraudChallenge", + "setRebateStaking", b.contractABI, b.transactor, - arg_walletPublicKey, - arg_preimageSha256, - arg_signature, + arg_rebateStaking, ) return result, err } // Transaction submission. -func (b *Bridge) SubmitMovedFundsSweepProof( - arg_sweepTx abi.BitcoinTxInfo, - arg_sweepProof abi.BitcoinTxProof, - arg_mainUtxo abi.BitcoinTxUTXO, +func (b *Bridge) SetRedemptionWatchtower( + arg_redemptionWatchtower common.Address, transactionOptions ...chainutil.TransactionOptions, ) (*types.Transaction, error) { bLogger.Debug( - "submitting transaction submitMovedFundsSweepProof", + "submitting transaction setRedemptionWatchtower", " params: ", fmt.Sprint( - arg_sweepTx, - arg_sweepProof, - arg_mainUtxo, + arg_redemptionWatchtower, ), ) @@ -4088,26 +3970,22 @@ func (b *Bridge) SubmitMovedFundsSweepProof( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := b.contract.SubmitMovedFundsSweepProof( + transaction, err := b.contract.SetRedemptionWatchtower( transactorOptions, - arg_sweepTx, - arg_sweepProof, - arg_mainUtxo, + arg_redemptionWatchtower, ) if err != nil { return transaction, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "submitMovedFundsSweepProof", - arg_sweepTx, - arg_sweepProof, - arg_mainUtxo, + "setRedemptionWatchtower", + arg_redemptionWatchtower, ) } bLogger.Infof( - "submitted transaction submitMovedFundsSweepProof with id: [%s] and nonce [%v]", + "submitted transaction setRedemptionWatchtower with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -4126,26 +4004,22 @@ func (b *Bridge) SubmitMovedFundsSweepProof( newTransactorOptions.GasLimit = transactorOptions.GasLimit } - transaction, err := b.contract.SubmitMovedFundsSweepProof( + transaction, err := b.contract.SetRedemptionWatchtower( newTransactorOptions, - arg_sweepTx, - arg_sweepProof, - arg_mainUtxo, + arg_redemptionWatchtower, ) if err != nil { return nil, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "submitMovedFundsSweepProof", - arg_sweepTx, - arg_sweepProof, - arg_mainUtxo, + "setRedemptionWatchtower", + arg_redemptionWatchtower, ) } bLogger.Infof( - "submitted transaction submitMovedFundsSweepProof with id: [%s] and nonce [%v]", + "submitted transaction setRedemptionWatchtower with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -4160,10 +4034,8 @@ func (b *Bridge) SubmitMovedFundsSweepProof( } // Non-mutating call, not a transaction submission. -func (b *Bridge) CallSubmitMovedFundsSweepProof( - arg_sweepTx abi.BitcoinTxInfo, - arg_sweepProof abi.BitcoinTxProof, - arg_mainUtxo abi.BitcoinTxUTXO, +func (b *Bridge) CallSetRedemptionWatchtower( + arg_redemptionWatchtower common.Address, blockNumber *big.Int, ) error { var result interface{} = nil @@ -4175,56 +4047,44 @@ func (b *Bridge) CallSubmitMovedFundsSweepProof( b.caller, b.errorResolver, b.contractAddress, - "submitMovedFundsSweepProof", + "setRedemptionWatchtower", &result, - arg_sweepTx, - arg_sweepProof, - arg_mainUtxo, + arg_redemptionWatchtower, ) return err } -func (b *Bridge) SubmitMovedFundsSweepProofGasEstimate( - arg_sweepTx abi.BitcoinTxInfo, - arg_sweepProof abi.BitcoinTxProof, - arg_mainUtxo abi.BitcoinTxUTXO, +func (b *Bridge) SetRedemptionWatchtowerGasEstimate( + arg_redemptionWatchtower common.Address, ) (uint64, error) { var result uint64 result, err := chainutil.EstimateGas( b.callerOptions.From, b.contractAddress, - "submitMovedFundsSweepProof", + "setRedemptionWatchtower", b.contractABI, b.transactor, - arg_sweepTx, - arg_sweepProof, - arg_mainUtxo, + arg_redemptionWatchtower, ) return result, err } // Transaction submission. -func (b *Bridge) SubmitMovingFundsCommitment( - arg_walletPubKeyHash [20]byte, - arg_walletMainUtxo abi.BitcoinTxUTXO, - arg_walletMembersIDs []uint32, - arg_walletMemberIndex *big.Int, - arg_targetWallets [][20]byte, +func (b *Bridge) SetSpvMaintainerStatus( + arg_spvMaintainer common.Address, + arg_isTrusted bool, transactionOptions ...chainutil.TransactionOptions, ) (*types.Transaction, error) { bLogger.Debug( - "submitting transaction submitMovingFundsCommitment", + "submitting transaction setSpvMaintainerStatus", " params: ", fmt.Sprint( - arg_walletPubKeyHash, - arg_walletMainUtxo, - arg_walletMembersIDs, - arg_walletMemberIndex, - arg_targetWallets, + arg_spvMaintainer, + arg_isTrusted, ), ) @@ -4250,30 +4110,24 @@ func (b *Bridge) SubmitMovingFundsCommitment( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := b.contract.SubmitMovingFundsCommitment( + transaction, err := b.contract.SetSpvMaintainerStatus( transactorOptions, - arg_walletPubKeyHash, - arg_walletMainUtxo, - arg_walletMembersIDs, - arg_walletMemberIndex, - arg_targetWallets, + arg_spvMaintainer, + arg_isTrusted, ) if err != nil { return transaction, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "submitMovingFundsCommitment", - arg_walletPubKeyHash, - arg_walletMainUtxo, - arg_walletMembersIDs, - arg_walletMemberIndex, - arg_targetWallets, + "setSpvMaintainerStatus", + arg_spvMaintainer, + arg_isTrusted, ) } bLogger.Infof( - "submitted transaction submitMovingFundsCommitment with id: [%s] and nonce [%v]", + "submitted transaction setSpvMaintainerStatus with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -4292,30 +4146,24 @@ func (b *Bridge) SubmitMovingFundsCommitment( newTransactorOptions.GasLimit = transactorOptions.GasLimit } - transaction, err := b.contract.SubmitMovingFundsCommitment( + transaction, err := b.contract.SetSpvMaintainerStatus( newTransactorOptions, - arg_walletPubKeyHash, - arg_walletMainUtxo, - arg_walletMembersIDs, - arg_walletMemberIndex, - arg_targetWallets, + arg_spvMaintainer, + arg_isTrusted, ) if err != nil { return nil, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "submitMovingFundsCommitment", - arg_walletPubKeyHash, - arg_walletMainUtxo, - arg_walletMembersIDs, - arg_walletMemberIndex, - arg_targetWallets, + "setSpvMaintainerStatus", + arg_spvMaintainer, + arg_isTrusted, ) } bLogger.Infof( - "submitted transaction submitMovingFundsCommitment with id: [%s] and nonce [%v]", + "submitted transaction setSpvMaintainerStatus with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -4330,12 +4178,9 @@ func (b *Bridge) SubmitMovingFundsCommitment( } // Non-mutating call, not a transaction submission. -func (b *Bridge) CallSubmitMovingFundsCommitment( - arg_walletPubKeyHash [20]byte, - arg_walletMainUtxo abi.BitcoinTxUTXO, - arg_walletMembersIDs []uint32, - arg_walletMemberIndex *big.Int, - arg_targetWallets [][20]byte, +func (b *Bridge) CallSetSpvMaintainerStatus( + arg_spvMaintainer common.Address, + arg_isTrusted bool, blockNumber *big.Int, ) error { var result interface{} = nil @@ -4347,60 +4192,47 @@ func (b *Bridge) CallSubmitMovingFundsCommitment( b.caller, b.errorResolver, b.contractAddress, - "submitMovingFundsCommitment", + "setSpvMaintainerStatus", &result, - arg_walletPubKeyHash, - arg_walletMainUtxo, - arg_walletMembersIDs, - arg_walletMemberIndex, - arg_targetWallets, + arg_spvMaintainer, + arg_isTrusted, ) return err } -func (b *Bridge) SubmitMovingFundsCommitmentGasEstimate( - arg_walletPubKeyHash [20]byte, - arg_walletMainUtxo abi.BitcoinTxUTXO, - arg_walletMembersIDs []uint32, - arg_walletMemberIndex *big.Int, - arg_targetWallets [][20]byte, +func (b *Bridge) SetSpvMaintainerStatusGasEstimate( + arg_spvMaintainer common.Address, + arg_isTrusted bool, ) (uint64, error) { var result uint64 result, err := chainutil.EstimateGas( b.callerOptions.From, b.contractAddress, - "submitMovingFundsCommitment", + "setSpvMaintainerStatus", b.contractABI, b.transactor, - arg_walletPubKeyHash, - arg_walletMainUtxo, - arg_walletMembersIDs, - arg_walletMemberIndex, - arg_targetWallets, + arg_spvMaintainer, + arg_isTrusted, ) return result, err } // Transaction submission. -func (b *Bridge) SubmitMovingFundsProof( - arg_movingFundsTx abi.BitcoinTxInfo, - arg_movingFundsProof abi.BitcoinTxProof, - arg_mainUtxo abi.BitcoinTxUTXO, - arg_walletPubKeyHash [20]byte, +func (b *Bridge) SetVaultStatus( + arg_vault common.Address, + arg_isTrusted bool, transactionOptions ...chainutil.TransactionOptions, ) (*types.Transaction, error) { bLogger.Debug( - "submitting transaction submitMovingFundsProof", + "submitting transaction setVaultStatus", " params: ", fmt.Sprint( - arg_movingFundsTx, - arg_movingFundsProof, - arg_mainUtxo, - arg_walletPubKeyHash, + arg_vault, + arg_isTrusted, ), ) @@ -4426,28 +4258,24 @@ func (b *Bridge) SubmitMovingFundsProof( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := b.contract.SubmitMovingFundsProof( + transaction, err := b.contract.SetVaultStatus( transactorOptions, - arg_movingFundsTx, - arg_movingFundsProof, - arg_mainUtxo, - arg_walletPubKeyHash, + arg_vault, + arg_isTrusted, ) if err != nil { return transaction, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "submitMovingFundsProof", - arg_movingFundsTx, - arg_movingFundsProof, - arg_mainUtxo, - arg_walletPubKeyHash, + "setVaultStatus", + arg_vault, + arg_isTrusted, ) } bLogger.Infof( - "submitted transaction submitMovingFundsProof with id: [%s] and nonce [%v]", + "submitted transaction setVaultStatus with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -4466,28 +4294,24 @@ func (b *Bridge) SubmitMovingFundsProof( newTransactorOptions.GasLimit = transactorOptions.GasLimit } - transaction, err := b.contract.SubmitMovingFundsProof( + transaction, err := b.contract.SetVaultStatus( newTransactorOptions, - arg_movingFundsTx, - arg_movingFundsProof, - arg_mainUtxo, - arg_walletPubKeyHash, + arg_vault, + arg_isTrusted, ) if err != nil { return nil, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "submitMovingFundsProof", - arg_movingFundsTx, - arg_movingFundsProof, - arg_mainUtxo, - arg_walletPubKeyHash, + "setVaultStatus", + arg_vault, + arg_isTrusted, ) } bLogger.Infof( - "submitted transaction submitMovingFundsProof with id: [%s] and nonce [%v]", + "submitted transaction setVaultStatus with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -4502,11 +4326,9 @@ func (b *Bridge) SubmitMovingFundsProof( } // Non-mutating call, not a transaction submission. -func (b *Bridge) CallSubmitMovingFundsProof( - arg_movingFundsTx abi.BitcoinTxInfo, - arg_movingFundsProof abi.BitcoinTxProof, - arg_mainUtxo abi.BitcoinTxUTXO, - arg_walletPubKeyHash [20]byte, +func (b *Bridge) CallSetVaultStatus( + arg_vault common.Address, + arg_isTrusted bool, blockNumber *big.Int, ) error { var result interface{} = nil @@ -4518,57 +4340,49 @@ func (b *Bridge) CallSubmitMovingFundsProof( b.caller, b.errorResolver, b.contractAddress, - "submitMovingFundsProof", + "setVaultStatus", &result, - arg_movingFundsTx, - arg_movingFundsProof, - arg_mainUtxo, - arg_walletPubKeyHash, + arg_vault, + arg_isTrusted, ) return err } -func (b *Bridge) SubmitMovingFundsProofGasEstimate( - arg_movingFundsTx abi.BitcoinTxInfo, - arg_movingFundsProof abi.BitcoinTxProof, - arg_mainUtxo abi.BitcoinTxUTXO, - arg_walletPubKeyHash [20]byte, +func (b *Bridge) SetVaultStatusGasEstimate( + arg_vault common.Address, + arg_isTrusted bool, ) (uint64, error) { var result uint64 result, err := chainutil.EstimateGas( b.callerOptions.From, b.contractAddress, - "submitMovingFundsProof", + "setVaultStatus", b.contractABI, b.transactor, - arg_movingFundsTx, - arg_movingFundsProof, - arg_mainUtxo, - arg_walletPubKeyHash, + arg_vault, + arg_isTrusted, ) return result, err } // Transaction submission. -func (b *Bridge) SubmitRedemptionProof( - arg_redemptionTx abi.BitcoinTxInfo, - arg_redemptionProof abi.BitcoinTxProof, - arg_mainUtxo abi.BitcoinTxUTXO, +func (b *Bridge) SlashWalletForFraud( arg_walletPubKeyHash [20]byte, + arg_walletMembersIDs []uint32, + arg_challenger common.Address, transactionOptions ...chainutil.TransactionOptions, ) (*types.Transaction, error) { bLogger.Debug( - "submitting transaction submitRedemptionProof", + "submitting transaction slashWalletForFraud", " params: ", fmt.Sprint( - arg_redemptionTx, - arg_redemptionProof, - arg_mainUtxo, arg_walletPubKeyHash, + arg_walletMembersIDs, + arg_challenger, ), ) @@ -4594,28 +4408,26 @@ func (b *Bridge) SubmitRedemptionProof( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := b.contract.SubmitRedemptionProof( + transaction, err := b.contract.SlashWalletForFraud( transactorOptions, - arg_redemptionTx, - arg_redemptionProof, - arg_mainUtxo, arg_walletPubKeyHash, + arg_walletMembersIDs, + arg_challenger, ) if err != nil { return transaction, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "submitRedemptionProof", - arg_redemptionTx, - arg_redemptionProof, - arg_mainUtxo, + "slashWalletForFraud", arg_walletPubKeyHash, + arg_walletMembersIDs, + arg_challenger, ) } bLogger.Infof( - "submitted transaction submitRedemptionProof with id: [%s] and nonce [%v]", + "submitted transaction slashWalletForFraud with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -4634,28 +4446,26 @@ func (b *Bridge) SubmitRedemptionProof( newTransactorOptions.GasLimit = transactorOptions.GasLimit } - transaction, err := b.contract.SubmitRedemptionProof( + transaction, err := b.contract.SlashWalletForFraud( newTransactorOptions, - arg_redemptionTx, - arg_redemptionProof, - arg_mainUtxo, arg_walletPubKeyHash, + arg_walletMembersIDs, + arg_challenger, ) if err != nil { return nil, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "submitRedemptionProof", - arg_redemptionTx, - arg_redemptionProof, - arg_mainUtxo, + "slashWalletForFraud", arg_walletPubKeyHash, + arg_walletMembersIDs, + arg_challenger, ) } bLogger.Infof( - "submitted transaction submitRedemptionProof with id: [%s] and nonce [%v]", + "submitted transaction slashWalletForFraud with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -4670,11 +4480,10 @@ func (b *Bridge) SubmitRedemptionProof( } // Non-mutating call, not a transaction submission. -func (b *Bridge) CallSubmitRedemptionProof( - arg_redemptionTx abi.BitcoinTxInfo, - arg_redemptionProof abi.BitcoinTxProof, - arg_mainUtxo abi.BitcoinTxUTXO, +func (b *Bridge) CallSlashWalletForFraud( arg_walletPubKeyHash [20]byte, + arg_walletMembersIDs []uint32, + arg_challenger common.Address, blockNumber *big.Int, ) error { var result interface{} = nil @@ -4686,51 +4495,52 @@ func (b *Bridge) CallSubmitRedemptionProof( b.caller, b.errorResolver, b.contractAddress, - "submitRedemptionProof", + "slashWalletForFraud", &result, - arg_redemptionTx, - arg_redemptionProof, - arg_mainUtxo, arg_walletPubKeyHash, + arg_walletMembersIDs, + arg_challenger, ) return err } -func (b *Bridge) SubmitRedemptionProofGasEstimate( - arg_redemptionTx abi.BitcoinTxInfo, - arg_redemptionProof abi.BitcoinTxProof, - arg_mainUtxo abi.BitcoinTxUTXO, +func (b *Bridge) SlashWalletForFraudGasEstimate( arg_walletPubKeyHash [20]byte, + arg_walletMembersIDs []uint32, + arg_challenger common.Address, ) (uint64, error) { var result uint64 result, err := chainutil.EstimateGas( b.callerOptions.From, b.contractAddress, - "submitRedemptionProof", + "slashWalletForFraud", b.contractABI, b.transactor, - arg_redemptionTx, - arg_redemptionProof, - arg_mainUtxo, arg_walletPubKeyHash, + arg_walletMembersIDs, + arg_challenger, ) return result, err } // Transaction submission. -func (b *Bridge) TransferGovernance( - arg_newGovernance common.Address, +func (b *Bridge) SlashWalletForP2TRFraud( + arg_walletPubKeyHash [20]byte, + arg_walletMembersIDs []uint32, + arg_challenger common.Address, transactionOptions ...chainutil.TransactionOptions, ) (*types.Transaction, error) { bLogger.Debug( - "submitting transaction transferGovernance", + "submitting transaction slashWalletForP2TRFraud", " params: ", fmt.Sprint( - arg_newGovernance, + arg_walletPubKeyHash, + arg_walletMembersIDs, + arg_challenger, ), ) @@ -4756,22 +4566,26 @@ func (b *Bridge) TransferGovernance( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := b.contract.TransferGovernance( + transaction, err := b.contract.SlashWalletForP2TRFraud( transactorOptions, - arg_newGovernance, + arg_walletPubKeyHash, + arg_walletMembersIDs, + arg_challenger, ) if err != nil { return transaction, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "transferGovernance", - arg_newGovernance, + "slashWalletForP2TRFraud", + arg_walletPubKeyHash, + arg_walletMembersIDs, + arg_challenger, ) } bLogger.Infof( - "submitted transaction transferGovernance with id: [%s] and nonce [%v]", + "submitted transaction slashWalletForP2TRFraud with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -4790,22 +4604,26 @@ func (b *Bridge) TransferGovernance( newTransactorOptions.GasLimit = transactorOptions.GasLimit } - transaction, err := b.contract.TransferGovernance( + transaction, err := b.contract.SlashWalletForP2TRFraud( newTransactorOptions, - arg_newGovernance, + arg_walletPubKeyHash, + arg_walletMembersIDs, + arg_challenger, ) if err != nil { return nil, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "transferGovernance", - arg_newGovernance, + "slashWalletForP2TRFraud", + arg_walletPubKeyHash, + arg_walletMembersIDs, + arg_challenger, ) } bLogger.Infof( - "submitted transaction transferGovernance with id: [%s] and nonce [%v]", + "submitted transaction slashWalletForP2TRFraud with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -4820,8 +4638,10 @@ func (b *Bridge) TransferGovernance( } // Non-mutating call, not a transaction submission. -func (b *Bridge) CallTransferGovernance( - arg_newGovernance common.Address, +func (b *Bridge) CallSlashWalletForP2TRFraud( + arg_walletPubKeyHash [20]byte, + arg_walletMembersIDs []uint32, + arg_challenger common.Address, blockNumber *big.Int, ) error { var result interface{} = nil @@ -4833,48 +4653,54 @@ func (b *Bridge) CallTransferGovernance( b.caller, b.errorResolver, b.contractAddress, - "transferGovernance", + "slashWalletForP2TRFraud", &result, - arg_newGovernance, + arg_walletPubKeyHash, + arg_walletMembersIDs, + arg_challenger, ) return err } -func (b *Bridge) TransferGovernanceGasEstimate( - arg_newGovernance common.Address, +func (b *Bridge) SlashWalletForP2TRFraudGasEstimate( + arg_walletPubKeyHash [20]byte, + arg_walletMembersIDs []uint32, + arg_challenger common.Address, ) (uint64, error) { var result uint64 result, err := chainutil.EstimateGas( b.callerOptions.From, b.contractAddress, - "transferGovernance", + "slashWalletForP2TRFraud", b.contractABI, b.transactor, - arg_newGovernance, + arg_walletPubKeyHash, + arg_walletMembersIDs, + arg_challenger, ) return result, err } // Transaction submission. -func (b *Bridge) UpdateDepositParameters( - arg_depositDustThreshold uint64, - arg_depositTreasuryFeeDivisor uint64, - arg_depositTxMaxFee uint64, - arg_depositRevealAheadPeriod uint32, +func (b *Bridge) SubmitDepositSweepProof( + arg_sweepTx abi.BitcoinTxInfo, + arg_sweepProof abi.BitcoinTxProof, + arg_mainUtxo abi.BitcoinTxUTXO, + arg_vault common.Address, transactionOptions ...chainutil.TransactionOptions, ) (*types.Transaction, error) { bLogger.Debug( - "submitting transaction updateDepositParameters", + "submitting transaction submitDepositSweepProof", " params: ", fmt.Sprint( - arg_depositDustThreshold, - arg_depositTreasuryFeeDivisor, - arg_depositTxMaxFee, - arg_depositRevealAheadPeriod, + arg_sweepTx, + arg_sweepProof, + arg_mainUtxo, + arg_vault, ), ) @@ -4900,28 +4726,28 @@ func (b *Bridge) UpdateDepositParameters( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := b.contract.UpdateDepositParameters( + transaction, err := b.contract.SubmitDepositSweepProof( transactorOptions, - arg_depositDustThreshold, - arg_depositTreasuryFeeDivisor, - arg_depositTxMaxFee, - arg_depositRevealAheadPeriod, + arg_sweepTx, + arg_sweepProof, + arg_mainUtxo, + arg_vault, ) if err != nil { return transaction, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "updateDepositParameters", - arg_depositDustThreshold, - arg_depositTreasuryFeeDivisor, - arg_depositTxMaxFee, - arg_depositRevealAheadPeriod, + "submitDepositSweepProof", + arg_sweepTx, + arg_sweepProof, + arg_mainUtxo, + arg_vault, ) } bLogger.Infof( - "submitted transaction updateDepositParameters with id: [%s] and nonce [%v]", + "submitted transaction submitDepositSweepProof with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -4940,28 +4766,28 @@ func (b *Bridge) UpdateDepositParameters( newTransactorOptions.GasLimit = transactorOptions.GasLimit } - transaction, err := b.contract.UpdateDepositParameters( + transaction, err := b.contract.SubmitDepositSweepProof( newTransactorOptions, - arg_depositDustThreshold, - arg_depositTreasuryFeeDivisor, - arg_depositTxMaxFee, - arg_depositRevealAheadPeriod, + arg_sweepTx, + arg_sweepProof, + arg_mainUtxo, + arg_vault, ) if err != nil { return nil, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "updateDepositParameters", - arg_depositDustThreshold, - arg_depositTreasuryFeeDivisor, - arg_depositTxMaxFee, - arg_depositRevealAheadPeriod, + "submitDepositSweepProof", + arg_sweepTx, + arg_sweepProof, + arg_mainUtxo, + arg_vault, ) } bLogger.Infof( - "submitted transaction updateDepositParameters with id: [%s] and nonce [%v]", + "submitted transaction submitDepositSweepProof with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -4976,11 +4802,11 @@ func (b *Bridge) UpdateDepositParameters( } // Non-mutating call, not a transaction submission. -func (b *Bridge) CallUpdateDepositParameters( - arg_depositDustThreshold uint64, - arg_depositTreasuryFeeDivisor uint64, - arg_depositTxMaxFee uint64, - arg_depositRevealAheadPeriod uint32, +func (b *Bridge) CallSubmitDepositSweepProof( + arg_sweepTx abi.BitcoinTxInfo, + arg_sweepProof abi.BitcoinTxProof, + arg_mainUtxo abi.BitcoinTxUTXO, + arg_vault common.Address, blockNumber *big.Int, ) error { var result interface{} = nil @@ -4992,57 +4818,55 @@ func (b *Bridge) CallUpdateDepositParameters( b.caller, b.errorResolver, b.contractAddress, - "updateDepositParameters", + "submitDepositSweepProof", &result, - arg_depositDustThreshold, - arg_depositTreasuryFeeDivisor, - arg_depositTxMaxFee, - arg_depositRevealAheadPeriod, + arg_sweepTx, + arg_sweepProof, + arg_mainUtxo, + arg_vault, ) return err } -func (b *Bridge) UpdateDepositParametersGasEstimate( - arg_depositDustThreshold uint64, - arg_depositTreasuryFeeDivisor uint64, - arg_depositTxMaxFee uint64, - arg_depositRevealAheadPeriod uint32, +func (b *Bridge) SubmitDepositSweepProofGasEstimate( + arg_sweepTx abi.BitcoinTxInfo, + arg_sweepProof abi.BitcoinTxProof, + arg_mainUtxo abi.BitcoinTxUTXO, + arg_vault common.Address, ) (uint64, error) { var result uint64 result, err := chainutil.EstimateGas( b.callerOptions.From, b.contractAddress, - "updateDepositParameters", + "submitDepositSweepProof", b.contractABI, b.transactor, - arg_depositDustThreshold, - arg_depositTreasuryFeeDivisor, - arg_depositTxMaxFee, - arg_depositRevealAheadPeriod, + arg_sweepTx, + arg_sweepProof, + arg_mainUtxo, + arg_vault, ) return result, err } // Transaction submission. -func (b *Bridge) UpdateFraudParameters( - arg_fraudChallengeDepositAmount *big.Int, - arg_fraudChallengeDefeatTimeout uint32, - arg_fraudSlashingAmount *big.Int, - arg_fraudNotifierRewardMultiplier uint32, +func (b *Bridge) SubmitMovedFundsSweepProof( + arg_sweepTx abi.BitcoinTxInfo, + arg_sweepProof abi.BitcoinTxProof, + arg_mainUtxo abi.BitcoinTxUTXO, transactionOptions ...chainutil.TransactionOptions, ) (*types.Transaction, error) { bLogger.Debug( - "submitting transaction updateFraudParameters", + "submitting transaction submitMovedFundsSweepProof", " params: ", fmt.Sprint( - arg_fraudChallengeDepositAmount, - arg_fraudChallengeDefeatTimeout, - arg_fraudSlashingAmount, - arg_fraudNotifierRewardMultiplier, + arg_sweepTx, + arg_sweepProof, + arg_mainUtxo, ), ) @@ -5068,28 +4892,26 @@ func (b *Bridge) UpdateFraudParameters( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := b.contract.UpdateFraudParameters( + transaction, err := b.contract.SubmitMovedFundsSweepProof( transactorOptions, - arg_fraudChallengeDepositAmount, - arg_fraudChallengeDefeatTimeout, - arg_fraudSlashingAmount, - arg_fraudNotifierRewardMultiplier, + arg_sweepTx, + arg_sweepProof, + arg_mainUtxo, ) if err != nil { return transaction, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "updateFraudParameters", - arg_fraudChallengeDepositAmount, - arg_fraudChallengeDefeatTimeout, - arg_fraudSlashingAmount, - arg_fraudNotifierRewardMultiplier, + "submitMovedFundsSweepProof", + arg_sweepTx, + arg_sweepProof, + arg_mainUtxo, ) } bLogger.Infof( - "submitted transaction updateFraudParameters with id: [%s] and nonce [%v]", + "submitted transaction submitMovedFundsSweepProof with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -5108,28 +4930,26 @@ func (b *Bridge) UpdateFraudParameters( newTransactorOptions.GasLimit = transactorOptions.GasLimit } - transaction, err := b.contract.UpdateFraudParameters( + transaction, err := b.contract.SubmitMovedFundsSweepProof( newTransactorOptions, - arg_fraudChallengeDepositAmount, - arg_fraudChallengeDefeatTimeout, - arg_fraudSlashingAmount, - arg_fraudNotifierRewardMultiplier, + arg_sweepTx, + arg_sweepProof, + arg_mainUtxo, ) if err != nil { return nil, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "updateFraudParameters", - arg_fraudChallengeDepositAmount, - arg_fraudChallengeDefeatTimeout, - arg_fraudSlashingAmount, - arg_fraudNotifierRewardMultiplier, + "submitMovedFundsSweepProof", + arg_sweepTx, + arg_sweepProof, + arg_mainUtxo, ) } bLogger.Infof( - "submitted transaction updateFraudParameters with id: [%s] and nonce [%v]", + "submitted transaction submitMovedFundsSweepProof with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -5144,11 +4964,10 @@ func (b *Bridge) UpdateFraudParameters( } // Non-mutating call, not a transaction submission. -func (b *Bridge) CallUpdateFraudParameters( - arg_fraudChallengeDepositAmount *big.Int, - arg_fraudChallengeDefeatTimeout uint32, - arg_fraudSlashingAmount *big.Int, - arg_fraudNotifierRewardMultiplier uint32, +func (b *Bridge) CallSubmitMovedFundsSweepProof( + arg_sweepTx abi.BitcoinTxInfo, + arg_sweepProof abi.BitcoinTxProof, + arg_mainUtxo abi.BitcoinTxUTXO, blockNumber *big.Int, ) error { var result interface{} = nil @@ -5160,74 +4979,59 @@ func (b *Bridge) CallUpdateFraudParameters( b.caller, b.errorResolver, b.contractAddress, - "updateFraudParameters", + "submitMovedFundsSweepProof", &result, - arg_fraudChallengeDepositAmount, - arg_fraudChallengeDefeatTimeout, - arg_fraudSlashingAmount, - arg_fraudNotifierRewardMultiplier, + arg_sweepTx, + arg_sweepProof, + arg_mainUtxo, ) return err } -func (b *Bridge) UpdateFraudParametersGasEstimate( - arg_fraudChallengeDepositAmount *big.Int, - arg_fraudChallengeDefeatTimeout uint32, - arg_fraudSlashingAmount *big.Int, - arg_fraudNotifierRewardMultiplier uint32, +func (b *Bridge) SubmitMovedFundsSweepProofGasEstimate( + arg_sweepTx abi.BitcoinTxInfo, + arg_sweepProof abi.BitcoinTxProof, + arg_mainUtxo abi.BitcoinTxUTXO, ) (uint64, error) { var result uint64 result, err := chainutil.EstimateGas( b.callerOptions.From, b.contractAddress, - "updateFraudParameters", + "submitMovedFundsSweepProof", b.contractABI, b.transactor, - arg_fraudChallengeDepositAmount, - arg_fraudChallengeDefeatTimeout, - arg_fraudSlashingAmount, - arg_fraudNotifierRewardMultiplier, + arg_sweepTx, + arg_sweepProof, + arg_mainUtxo, ) return result, err } // Transaction submission. -func (b *Bridge) UpdateMovingFundsParameters( - arg_movingFundsTxMaxTotalFee uint64, - arg_movingFundsDustThreshold uint64, - arg_movingFundsTimeoutResetDelay uint32, - arg_movingFundsTimeout uint32, - arg_movingFundsTimeoutSlashingAmount *big.Int, - arg_movingFundsTimeoutNotifierRewardMultiplier uint32, - arg_movingFundsCommitmentGasOffset uint16, - arg_movedFundsSweepTxMaxTotalFee uint64, - arg_movedFundsSweepTimeout uint32, - arg_movedFundsSweepTimeoutSlashingAmount *big.Int, - arg_movedFundsSweepTimeoutNotifierRewardMultiplier uint32, +func (b *Bridge) SubmitMovingFundsCommitment( + arg_walletPubKeyHash [20]byte, + arg_walletMainUtxo abi.BitcoinTxUTXO, + arg_walletMembersIDs []uint32, + arg_walletMemberIndex *big.Int, + arg_targetWallets [][20]byte, transactionOptions ...chainutil.TransactionOptions, ) (*types.Transaction, error) { bLogger.Debug( - "submitting transaction updateMovingFundsParameters", + "submitting transaction submitMovingFundsCommitment", " params: ", fmt.Sprint( - arg_movingFundsTxMaxTotalFee, - arg_movingFundsDustThreshold, - arg_movingFundsTimeoutResetDelay, - arg_movingFundsTimeout, - arg_movingFundsTimeoutSlashingAmount, - arg_movingFundsTimeoutNotifierRewardMultiplier, - arg_movingFundsCommitmentGasOffset, - arg_movedFundsSweepTxMaxTotalFee, - arg_movedFundsSweepTimeout, - arg_movedFundsSweepTimeoutSlashingAmount, - arg_movedFundsSweepTimeoutNotifierRewardMultiplier, - ), - ) - + arg_walletPubKeyHash, + arg_walletMainUtxo, + arg_walletMembersIDs, + arg_walletMemberIndex, + arg_targetWallets, + ), + ) + b.transactionMutex.Lock() defer b.transactionMutex.Unlock() @@ -5250,42 +5054,30 @@ func (b *Bridge) UpdateMovingFundsParameters( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := b.contract.UpdateMovingFundsParameters( + transaction, err := b.contract.SubmitMovingFundsCommitment( transactorOptions, - arg_movingFundsTxMaxTotalFee, - arg_movingFundsDustThreshold, - arg_movingFundsTimeoutResetDelay, - arg_movingFundsTimeout, - arg_movingFundsTimeoutSlashingAmount, - arg_movingFundsTimeoutNotifierRewardMultiplier, - arg_movingFundsCommitmentGasOffset, - arg_movedFundsSweepTxMaxTotalFee, - arg_movedFundsSweepTimeout, - arg_movedFundsSweepTimeoutSlashingAmount, - arg_movedFundsSweepTimeoutNotifierRewardMultiplier, + arg_walletPubKeyHash, + arg_walletMainUtxo, + arg_walletMembersIDs, + arg_walletMemberIndex, + arg_targetWallets, ) if err != nil { return transaction, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "updateMovingFundsParameters", - arg_movingFundsTxMaxTotalFee, - arg_movingFundsDustThreshold, - arg_movingFundsTimeoutResetDelay, - arg_movingFundsTimeout, - arg_movingFundsTimeoutSlashingAmount, - arg_movingFundsTimeoutNotifierRewardMultiplier, - arg_movingFundsCommitmentGasOffset, - arg_movedFundsSweepTxMaxTotalFee, - arg_movedFundsSweepTimeout, - arg_movedFundsSweepTimeoutSlashingAmount, - arg_movedFundsSweepTimeoutNotifierRewardMultiplier, + "submitMovingFundsCommitment", + arg_walletPubKeyHash, + arg_walletMainUtxo, + arg_walletMembersIDs, + arg_walletMemberIndex, + arg_targetWallets, ) } bLogger.Infof( - "submitted transaction updateMovingFundsParameters with id: [%s] and nonce [%v]", + "submitted transaction submitMovingFundsCommitment with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -5304,42 +5096,30 @@ func (b *Bridge) UpdateMovingFundsParameters( newTransactorOptions.GasLimit = transactorOptions.GasLimit } - transaction, err := b.contract.UpdateMovingFundsParameters( + transaction, err := b.contract.SubmitMovingFundsCommitment( newTransactorOptions, - arg_movingFundsTxMaxTotalFee, - arg_movingFundsDustThreshold, - arg_movingFundsTimeoutResetDelay, - arg_movingFundsTimeout, - arg_movingFundsTimeoutSlashingAmount, - arg_movingFundsTimeoutNotifierRewardMultiplier, - arg_movingFundsCommitmentGasOffset, - arg_movedFundsSweepTxMaxTotalFee, - arg_movedFundsSweepTimeout, - arg_movedFundsSweepTimeoutSlashingAmount, - arg_movedFundsSweepTimeoutNotifierRewardMultiplier, + arg_walletPubKeyHash, + arg_walletMainUtxo, + arg_walletMembersIDs, + arg_walletMemberIndex, + arg_targetWallets, ) if err != nil { return nil, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "updateMovingFundsParameters", - arg_movingFundsTxMaxTotalFee, - arg_movingFundsDustThreshold, - arg_movingFundsTimeoutResetDelay, - arg_movingFundsTimeout, - arg_movingFundsTimeoutSlashingAmount, - arg_movingFundsTimeoutNotifierRewardMultiplier, - arg_movingFundsCommitmentGasOffset, - arg_movedFundsSweepTxMaxTotalFee, - arg_movedFundsSweepTimeout, - arg_movedFundsSweepTimeoutSlashingAmount, - arg_movedFundsSweepTimeoutNotifierRewardMultiplier, + "submitMovingFundsCommitment", + arg_walletPubKeyHash, + arg_walletMainUtxo, + arg_walletMembersIDs, + arg_walletMemberIndex, + arg_targetWallets, ) } bLogger.Infof( - "submitted transaction updateMovingFundsParameters with id: [%s] and nonce [%v]", + "submitted transaction submitMovingFundsCommitment with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -5354,18 +5134,12 @@ func (b *Bridge) UpdateMovingFundsParameters( } // Non-mutating call, not a transaction submission. -func (b *Bridge) CallUpdateMovingFundsParameters( - arg_movingFundsTxMaxTotalFee uint64, - arg_movingFundsDustThreshold uint64, - arg_movingFundsTimeoutResetDelay uint32, - arg_movingFundsTimeout uint32, - arg_movingFundsTimeoutSlashingAmount *big.Int, - arg_movingFundsTimeoutNotifierRewardMultiplier uint32, - arg_movingFundsCommitmentGasOffset uint16, - arg_movedFundsSweepTxMaxTotalFee uint64, - arg_movedFundsSweepTimeout uint32, - arg_movedFundsSweepTimeoutSlashingAmount *big.Int, - arg_movedFundsSweepTimeoutNotifierRewardMultiplier uint32, +func (b *Bridge) CallSubmitMovingFundsCommitment( + arg_walletPubKeyHash [20]byte, + arg_walletMainUtxo abi.BitcoinTxUTXO, + arg_walletMembersIDs []uint32, + arg_walletMemberIndex *big.Int, + arg_targetWallets [][20]byte, blockNumber *big.Int, ) error { var result interface{} = nil @@ -5377,84 +5151,60 @@ func (b *Bridge) CallUpdateMovingFundsParameters( b.caller, b.errorResolver, b.contractAddress, - "updateMovingFundsParameters", + "submitMovingFundsCommitment", &result, - arg_movingFundsTxMaxTotalFee, - arg_movingFundsDustThreshold, - arg_movingFundsTimeoutResetDelay, - arg_movingFundsTimeout, - arg_movingFundsTimeoutSlashingAmount, - arg_movingFundsTimeoutNotifierRewardMultiplier, - arg_movingFundsCommitmentGasOffset, - arg_movedFundsSweepTxMaxTotalFee, - arg_movedFundsSweepTimeout, - arg_movedFundsSweepTimeoutSlashingAmount, - arg_movedFundsSweepTimeoutNotifierRewardMultiplier, + arg_walletPubKeyHash, + arg_walletMainUtxo, + arg_walletMembersIDs, + arg_walletMemberIndex, + arg_targetWallets, ) return err } -func (b *Bridge) UpdateMovingFundsParametersGasEstimate( - arg_movingFundsTxMaxTotalFee uint64, - arg_movingFundsDustThreshold uint64, - arg_movingFundsTimeoutResetDelay uint32, - arg_movingFundsTimeout uint32, - arg_movingFundsTimeoutSlashingAmount *big.Int, - arg_movingFundsTimeoutNotifierRewardMultiplier uint32, - arg_movingFundsCommitmentGasOffset uint16, - arg_movedFundsSweepTxMaxTotalFee uint64, - arg_movedFundsSweepTimeout uint32, - arg_movedFundsSweepTimeoutSlashingAmount *big.Int, - arg_movedFundsSweepTimeoutNotifierRewardMultiplier uint32, +func (b *Bridge) SubmitMovingFundsCommitmentGasEstimate( + arg_walletPubKeyHash [20]byte, + arg_walletMainUtxo abi.BitcoinTxUTXO, + arg_walletMembersIDs []uint32, + arg_walletMemberIndex *big.Int, + arg_targetWallets [][20]byte, ) (uint64, error) { var result uint64 result, err := chainutil.EstimateGas( b.callerOptions.From, b.contractAddress, - "updateMovingFundsParameters", + "submitMovingFundsCommitment", b.contractABI, b.transactor, - arg_movingFundsTxMaxTotalFee, - arg_movingFundsDustThreshold, - arg_movingFundsTimeoutResetDelay, - arg_movingFundsTimeout, - arg_movingFundsTimeoutSlashingAmount, - arg_movingFundsTimeoutNotifierRewardMultiplier, - arg_movingFundsCommitmentGasOffset, - arg_movedFundsSweepTxMaxTotalFee, - arg_movedFundsSweepTimeout, - arg_movedFundsSweepTimeoutSlashingAmount, - arg_movedFundsSweepTimeoutNotifierRewardMultiplier, + arg_walletPubKeyHash, + arg_walletMainUtxo, + arg_walletMembersIDs, + arg_walletMemberIndex, + arg_targetWallets, ) return result, err } // Transaction submission. -func (b *Bridge) UpdateRedemptionParameters( - arg_redemptionDustThreshold uint64, - arg_redemptionTreasuryFeeDivisor uint64, - arg_redemptionTxMaxFee uint64, - arg_redemptionTxMaxTotalFee uint64, - arg_redemptionTimeout uint32, - arg_redemptionTimeoutSlashingAmount *big.Int, - arg_redemptionTimeoutNotifierRewardMultiplier uint32, +func (b *Bridge) SubmitMovingFundsProof( + arg_movingFundsTx abi.BitcoinTxInfo, + arg_movingFundsProof abi.BitcoinTxProof, + arg_mainUtxo abi.BitcoinTxUTXO, + arg_walletPubKeyHash [20]byte, transactionOptions ...chainutil.TransactionOptions, ) (*types.Transaction, error) { bLogger.Debug( - "submitting transaction updateRedemptionParameters", + "submitting transaction submitMovingFundsProof", " params: ", fmt.Sprint( - arg_redemptionDustThreshold, - arg_redemptionTreasuryFeeDivisor, - arg_redemptionTxMaxFee, - arg_redemptionTxMaxTotalFee, - arg_redemptionTimeout, - arg_redemptionTimeoutSlashingAmount, - arg_redemptionTimeoutNotifierRewardMultiplier, + arg_movingFundsTx, + arg_movingFundsProof, + arg_mainUtxo, + arg_walletPubKeyHash, ), ) @@ -5480,34 +5230,28 @@ func (b *Bridge) UpdateRedemptionParameters( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := b.contract.UpdateRedemptionParameters( + transaction, err := b.contract.SubmitMovingFundsProof( transactorOptions, - arg_redemptionDustThreshold, - arg_redemptionTreasuryFeeDivisor, - arg_redemptionTxMaxFee, - arg_redemptionTxMaxTotalFee, - arg_redemptionTimeout, - arg_redemptionTimeoutSlashingAmount, - arg_redemptionTimeoutNotifierRewardMultiplier, + arg_movingFundsTx, + arg_movingFundsProof, + arg_mainUtxo, + arg_walletPubKeyHash, ) if err != nil { return transaction, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "updateRedemptionParameters", - arg_redemptionDustThreshold, - arg_redemptionTreasuryFeeDivisor, - arg_redemptionTxMaxFee, - arg_redemptionTxMaxTotalFee, - arg_redemptionTimeout, - arg_redemptionTimeoutSlashingAmount, - arg_redemptionTimeoutNotifierRewardMultiplier, + "submitMovingFundsProof", + arg_movingFundsTx, + arg_movingFundsProof, + arg_mainUtxo, + arg_walletPubKeyHash, ) } bLogger.Infof( - "submitted transaction updateRedemptionParameters with id: [%s] and nonce [%v]", + "submitted transaction submitMovingFundsProof with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -5526,34 +5270,28 @@ func (b *Bridge) UpdateRedemptionParameters( newTransactorOptions.GasLimit = transactorOptions.GasLimit } - transaction, err := b.contract.UpdateRedemptionParameters( + transaction, err := b.contract.SubmitMovingFundsProof( newTransactorOptions, - arg_redemptionDustThreshold, - arg_redemptionTreasuryFeeDivisor, - arg_redemptionTxMaxFee, - arg_redemptionTxMaxTotalFee, - arg_redemptionTimeout, - arg_redemptionTimeoutSlashingAmount, - arg_redemptionTimeoutNotifierRewardMultiplier, + arg_movingFundsTx, + arg_movingFundsProof, + arg_mainUtxo, + arg_walletPubKeyHash, ) if err != nil { return nil, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "updateRedemptionParameters", - arg_redemptionDustThreshold, - arg_redemptionTreasuryFeeDivisor, - arg_redemptionTxMaxFee, - arg_redemptionTxMaxTotalFee, - arg_redemptionTimeout, - arg_redemptionTimeoutSlashingAmount, - arg_redemptionTimeoutNotifierRewardMultiplier, + "submitMovingFundsProof", + arg_movingFundsTx, + arg_movingFundsProof, + arg_mainUtxo, + arg_walletPubKeyHash, ) } bLogger.Infof( - "submitted transaction updateRedemptionParameters with id: [%s] and nonce [%v]", + "submitted transaction submitMovingFundsProof with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -5568,14 +5306,11 @@ func (b *Bridge) UpdateRedemptionParameters( } // Non-mutating call, not a transaction submission. -func (b *Bridge) CallUpdateRedemptionParameters( - arg_redemptionDustThreshold uint64, - arg_redemptionTreasuryFeeDivisor uint64, - arg_redemptionTxMaxFee uint64, - arg_redemptionTxMaxTotalFee uint64, - arg_redemptionTimeout uint32, - arg_redemptionTimeoutSlashingAmount *big.Int, - arg_redemptionTimeoutNotifierRewardMultiplier uint32, +func (b *Bridge) CallSubmitMovingFundsProof( + arg_movingFundsTx abi.BitcoinTxInfo, + arg_movingFundsProof abi.BitcoinTxProof, + arg_mainUtxo abi.BitcoinTxUTXO, + arg_walletPubKeyHash [20]byte, blockNumber *big.Int, ) error { var result interface{} = nil @@ -5587,60 +5322,57 @@ func (b *Bridge) CallUpdateRedemptionParameters( b.caller, b.errorResolver, b.contractAddress, - "updateRedemptionParameters", + "submitMovingFundsProof", &result, - arg_redemptionDustThreshold, - arg_redemptionTreasuryFeeDivisor, - arg_redemptionTxMaxFee, - arg_redemptionTxMaxTotalFee, - arg_redemptionTimeout, - arg_redemptionTimeoutSlashingAmount, - arg_redemptionTimeoutNotifierRewardMultiplier, + arg_movingFundsTx, + arg_movingFundsProof, + arg_mainUtxo, + arg_walletPubKeyHash, ) return err } -func (b *Bridge) UpdateRedemptionParametersGasEstimate( - arg_redemptionDustThreshold uint64, - arg_redemptionTreasuryFeeDivisor uint64, - arg_redemptionTxMaxFee uint64, - arg_redemptionTxMaxTotalFee uint64, - arg_redemptionTimeout uint32, - arg_redemptionTimeoutSlashingAmount *big.Int, - arg_redemptionTimeoutNotifierRewardMultiplier uint32, +func (b *Bridge) SubmitMovingFundsProofGasEstimate( + arg_movingFundsTx abi.BitcoinTxInfo, + arg_movingFundsProof abi.BitcoinTxProof, + arg_mainUtxo abi.BitcoinTxUTXO, + arg_walletPubKeyHash [20]byte, ) (uint64, error) { var result uint64 result, err := chainutil.EstimateGas( b.callerOptions.From, b.contractAddress, - "updateRedemptionParameters", + "submitMovingFundsProof", b.contractABI, b.transactor, - arg_redemptionDustThreshold, - arg_redemptionTreasuryFeeDivisor, - arg_redemptionTxMaxFee, - arg_redemptionTxMaxTotalFee, - arg_redemptionTimeout, - arg_redemptionTimeoutSlashingAmount, - arg_redemptionTimeoutNotifierRewardMultiplier, + arg_movingFundsTx, + arg_movingFundsProof, + arg_mainUtxo, + arg_walletPubKeyHash, ) return result, err } // Transaction submission. -func (b *Bridge) UpdateTreasury( - arg_treasury common.Address, +func (b *Bridge) SubmitRedemptionProof( + arg_redemptionTx abi.BitcoinTxInfo, + arg_redemptionProof abi.BitcoinTxProof, + arg_mainUtxo abi.BitcoinTxUTXO, + arg_walletPubKeyHash [20]byte, transactionOptions ...chainutil.TransactionOptions, ) (*types.Transaction, error) { bLogger.Debug( - "submitting transaction updateTreasury", + "submitting transaction submitRedemptionProof", " params: ", fmt.Sprint( - arg_treasury, + arg_redemptionTx, + arg_redemptionProof, + arg_mainUtxo, + arg_walletPubKeyHash, ), ) @@ -5666,22 +5398,28 @@ func (b *Bridge) UpdateTreasury( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := b.contract.UpdateTreasury( + transaction, err := b.contract.SubmitRedemptionProof( transactorOptions, - arg_treasury, + arg_redemptionTx, + arg_redemptionProof, + arg_mainUtxo, + arg_walletPubKeyHash, ) if err != nil { return transaction, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "updateTreasury", - arg_treasury, + "submitRedemptionProof", + arg_redemptionTx, + arg_redemptionProof, + arg_mainUtxo, + arg_walletPubKeyHash, ) } bLogger.Infof( - "submitted transaction updateTreasury with id: [%s] and nonce [%v]", + "submitted transaction submitRedemptionProof with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -5700,22 +5438,28 @@ func (b *Bridge) UpdateTreasury( newTransactorOptions.GasLimit = transactorOptions.GasLimit } - transaction, err := b.contract.UpdateTreasury( + transaction, err := b.contract.SubmitRedemptionProof( newTransactorOptions, - arg_treasury, + arg_redemptionTx, + arg_redemptionProof, + arg_mainUtxo, + arg_walletPubKeyHash, ) if err != nil { return nil, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "updateTreasury", - arg_treasury, + "submitRedemptionProof", + arg_redemptionTx, + arg_redemptionProof, + arg_mainUtxo, + arg_walletPubKeyHash, ) } bLogger.Infof( - "submitted transaction updateTreasury with id: [%s] and nonce [%v]", + "submitted transaction submitRedemptionProof with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -5730,8 +5474,11 @@ func (b *Bridge) UpdateTreasury( } // Non-mutating call, not a transaction submission. -func (b *Bridge) CallUpdateTreasury( - arg_treasury common.Address, +func (b *Bridge) CallSubmitRedemptionProof( + arg_redemptionTx abi.BitcoinTxInfo, + arg_redemptionProof abi.BitcoinTxProof, + arg_mainUtxo abi.BitcoinTxUTXO, + arg_walletPubKeyHash [20]byte, blockNumber *big.Int, ) error { var result interface{} = nil @@ -5743,54 +5490,51 @@ func (b *Bridge) CallUpdateTreasury( b.caller, b.errorResolver, b.contractAddress, - "updateTreasury", + "submitRedemptionProof", &result, - arg_treasury, + arg_redemptionTx, + arg_redemptionProof, + arg_mainUtxo, + arg_walletPubKeyHash, ) return err } -func (b *Bridge) UpdateTreasuryGasEstimate( - arg_treasury common.Address, +func (b *Bridge) SubmitRedemptionProofGasEstimate( + arg_redemptionTx abi.BitcoinTxInfo, + arg_redemptionProof abi.BitcoinTxProof, + arg_mainUtxo abi.BitcoinTxUTXO, + arg_walletPubKeyHash [20]byte, ) (uint64, error) { var result uint64 result, err := chainutil.EstimateGas( b.callerOptions.From, b.contractAddress, - "updateTreasury", + "submitRedemptionProof", b.contractABI, b.transactor, - arg_treasury, + arg_redemptionTx, + arg_redemptionProof, + arg_mainUtxo, + arg_walletPubKeyHash, ) return result, err } // Transaction submission. -func (b *Bridge) UpdateWalletParameters( - arg_walletCreationPeriod uint32, - arg_walletCreationMinBtcBalance uint64, - arg_walletCreationMaxBtcBalance uint64, - arg_walletClosureMinBtcBalance uint64, - arg_walletMaxAge uint32, - arg_walletMaxBtcTransfer uint64, - arg_walletClosingPeriod uint32, +func (b *Bridge) TransferGovernance( + arg_newGovernance common.Address, transactionOptions ...chainutil.TransactionOptions, ) (*types.Transaction, error) { bLogger.Debug( - "submitting transaction updateWalletParameters", + "submitting transaction transferGovernance", " params: ", fmt.Sprint( - arg_walletCreationPeriod, - arg_walletCreationMinBtcBalance, - arg_walletCreationMaxBtcBalance, - arg_walletClosureMinBtcBalance, - arg_walletMaxAge, - arg_walletMaxBtcTransfer, - arg_walletClosingPeriod, + arg_newGovernance, ), ) @@ -5816,34 +5560,22 @@ func (b *Bridge) UpdateWalletParameters( transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - transaction, err := b.contract.UpdateWalletParameters( + transaction, err := b.contract.TransferGovernance( transactorOptions, - arg_walletCreationPeriod, - arg_walletCreationMinBtcBalance, - arg_walletCreationMaxBtcBalance, - arg_walletClosureMinBtcBalance, - arg_walletMaxAge, - arg_walletMaxBtcTransfer, - arg_walletClosingPeriod, + arg_newGovernance, ) if err != nil { return transaction, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "updateWalletParameters", - arg_walletCreationPeriod, - arg_walletCreationMinBtcBalance, - arg_walletCreationMaxBtcBalance, - arg_walletClosureMinBtcBalance, - arg_walletMaxAge, - arg_walletMaxBtcTransfer, - arg_walletClosingPeriod, + "transferGovernance", + arg_newGovernance, ) } bLogger.Infof( - "submitted transaction updateWalletParameters with id: [%s] and nonce [%v]", + "submitted transaction transferGovernance with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -5862,34 +5594,22 @@ func (b *Bridge) UpdateWalletParameters( newTransactorOptions.GasLimit = transactorOptions.GasLimit } - transaction, err := b.contract.UpdateWalletParameters( + transaction, err := b.contract.TransferGovernance( newTransactorOptions, - arg_walletCreationPeriod, - arg_walletCreationMinBtcBalance, - arg_walletCreationMaxBtcBalance, - arg_walletClosureMinBtcBalance, - arg_walletMaxAge, - arg_walletMaxBtcTransfer, - arg_walletClosingPeriod, + arg_newGovernance, ) if err != nil { return nil, b.errorResolver.ResolveError( err, b.transactorOptions.From, nil, - "updateWalletParameters", - arg_walletCreationPeriod, - arg_walletCreationMinBtcBalance, - arg_walletCreationMaxBtcBalance, - arg_walletClosureMinBtcBalance, - arg_walletMaxAge, - arg_walletMaxBtcTransfer, - arg_walletClosingPeriod, + "transferGovernance", + arg_newGovernance, ) } bLogger.Infof( - "submitted transaction updateWalletParameters with id: [%s] and nonce [%v]", + "submitted transaction transferGovernance with id: [%s] and nonce [%v]", transaction.Hash(), transaction.Nonce(), ) @@ -5904,14 +5624,8 @@ func (b *Bridge) UpdateWalletParameters( } // Non-mutating call, not a transaction submission. -func (b *Bridge) CallUpdateWalletParameters( - arg_walletCreationPeriod uint32, - arg_walletCreationMinBtcBalance uint64, - arg_walletCreationMaxBtcBalance uint64, - arg_walletClosureMinBtcBalance uint64, - arg_walletMaxAge uint32, - arg_walletMaxBtcTransfer uint64, - arg_walletClosingPeriod uint32, +func (b *Bridge) CallTransferGovernance( + arg_newGovernance common.Address, blockNumber *big.Int, ) error { var result interface{} = nil @@ -5923,933 +5637,1143 @@ func (b *Bridge) CallUpdateWalletParameters( b.caller, b.errorResolver, b.contractAddress, - "updateWalletParameters", + "transferGovernance", &result, - arg_walletCreationPeriod, - arg_walletCreationMinBtcBalance, - arg_walletCreationMaxBtcBalance, - arg_walletClosureMinBtcBalance, - arg_walletMaxAge, - arg_walletMaxBtcTransfer, - arg_walletClosingPeriod, + arg_newGovernance, ) return err } -func (b *Bridge) UpdateWalletParametersGasEstimate( - arg_walletCreationPeriod uint32, - arg_walletCreationMinBtcBalance uint64, - arg_walletCreationMaxBtcBalance uint64, - arg_walletClosureMinBtcBalance uint64, - arg_walletMaxAge uint32, - arg_walletMaxBtcTransfer uint64, - arg_walletClosingPeriod uint32, +func (b *Bridge) TransferGovernanceGasEstimate( + arg_newGovernance common.Address, ) (uint64, error) { var result uint64 result, err := chainutil.EstimateGas( b.callerOptions.From, b.contractAddress, - "updateWalletParameters", + "transferGovernance", b.contractABI, b.transactor, - arg_walletCreationPeriod, - arg_walletCreationMinBtcBalance, - arg_walletCreationMaxBtcBalance, - arg_walletClosureMinBtcBalance, - arg_walletMaxAge, - arg_walletMaxBtcTransfer, - arg_walletClosingPeriod, + arg_newGovernance, ) return result, err } -// ----- Const Methods ------ +// Transaction submission. +func (b *Bridge) UpdateDepositParameters( + arg_depositDustThreshold uint64, + arg_depositTreasuryFeeDivisor uint64, + arg_depositTxMaxFee uint64, + arg_depositRevealAheadPeriod uint32, -func (b *Bridge) ActiveWalletID() ([32]byte, error) { - result, err := b.contract.ActiveWalletID( - b.callerOptions, + transactionOptions ...chainutil.TransactionOptions, +) (*types.Transaction, error) { + bLogger.Debug( + "submitting transaction updateDepositParameters", + " params: ", + fmt.Sprint( + arg_depositDustThreshold, + arg_depositTreasuryFeeDivisor, + arg_depositTxMaxFee, + arg_depositRevealAheadPeriod, + ), ) - if err != nil { - return result, b.errorResolver.ResolveError( - err, - b.callerOptions.From, - nil, - "activeWalletID", + b.transactionMutex.Lock() + defer b.transactionMutex.Unlock() + + // create a copy + transactorOptions := new(bind.TransactOpts) + *transactorOptions = *b.transactorOptions + + if len(transactionOptions) > 1 { + return nil, fmt.Errorf( + "could not process multiple transaction options sets", ) + } else if len(transactionOptions) > 0 { + transactionOptions[0].Apply(transactorOptions) } - return result, err -} - -func (b *Bridge) ActiveWalletIDAtBlock( - blockNumber *big.Int, -) ([32]byte, error) { - var result [32]byte - - err := chainutil.CallAtBlock( - b.callerOptions.From, - blockNumber, - nil, - b.contractABI, - b.caller, - b.errorResolver, - b.contractAddress, - "activeWalletID", - &result, - ) + nonce, err := b.nonceManager.CurrentNonce() + if err != nil { + return nil, fmt.Errorf("failed to retrieve account nonce: %v", err) + } - return result, err -} + transactorOptions.Nonce = new(big.Int).SetUint64(nonce) -func (b *Bridge) ActiveWalletPubKeyHash() ([20]byte, error) { - result, err := b.contract.ActiveWalletPubKeyHash( - b.callerOptions, + transaction, err := b.contract.UpdateDepositParameters( + transactorOptions, + arg_depositDustThreshold, + arg_depositTreasuryFeeDivisor, + arg_depositTxMaxFee, + arg_depositRevealAheadPeriod, ) - if err != nil { - return result, b.errorResolver.ResolveError( + return transaction, b.errorResolver.ResolveError( err, - b.callerOptions.From, + b.transactorOptions.From, nil, - "activeWalletPubKeyHash", + "updateDepositParameters", + arg_depositDustThreshold, + arg_depositTreasuryFeeDivisor, + arg_depositTxMaxFee, + arg_depositRevealAheadPeriod, ) } - return result, err -} - -func (b *Bridge) ActiveWalletPubKeyHashAtBlock( - blockNumber *big.Int, -) ([20]byte, error) { - var result [20]byte - - err := chainutil.CallAtBlock( - b.callerOptions.From, - blockNumber, - nil, - b.contractABI, - b.caller, - b.errorResolver, - b.contractAddress, - "activeWalletPubKeyHash", - &result, + bLogger.Infof( + "submitted transaction updateDepositParameters with id: [%s] and nonce [%v]", + transaction.Hash(), + transaction.Nonce(), ) - return result, err -} + go b.miningWaiter.ForceMining( + transaction, + transactorOptions, + func(newTransactorOptions *bind.TransactOpts) (*types.Transaction, error) { + // If original transactor options has a non-zero gas limit, that + // means the client code set it on their own. In that case, we + // should rewrite the gas limit from the original transaction + // for each resubmission. If the gas limit is not set by the client + // code, let the the submitter re-estimate the gas limit on each + // resubmission. + if transactorOptions.GasLimit != 0 { + newTransactorOptions.GasLimit = transactorOptions.GasLimit + } -type contractReferences struct { - Bank common.Address - Relay common.Address - EcdsaWalletRegistry common.Address - ReimbursementPool common.Address -} + transaction, err := b.contract.UpdateDepositParameters( + newTransactorOptions, + arg_depositDustThreshold, + arg_depositTreasuryFeeDivisor, + arg_depositTxMaxFee, + arg_depositRevealAheadPeriod, + ) + if err != nil { + return nil, b.errorResolver.ResolveError( + err, + b.transactorOptions.From, + nil, + "updateDepositParameters", + arg_depositDustThreshold, + arg_depositTreasuryFeeDivisor, + arg_depositTxMaxFee, + arg_depositRevealAheadPeriod, + ) + } -func (b *Bridge) ContractReferences() (contractReferences, error) { - result, err := b.contract.ContractReferences( - b.callerOptions, + bLogger.Infof( + "submitted transaction updateDepositParameters with id: [%s] and nonce [%v]", + transaction.Hash(), + transaction.Nonce(), + ) + + return transaction, nil + }, ) - if err != nil { - return result, b.errorResolver.ResolveError( - err, - b.callerOptions.From, - nil, - "contractReferences", - ) - } + b.nonceManager.IncrementNonce() - return result, err + return transaction, err } -func (b *Bridge) ContractReferencesAtBlock( +// Non-mutating call, not a transaction submission. +func (b *Bridge) CallUpdateDepositParameters( + arg_depositDustThreshold uint64, + arg_depositTreasuryFeeDivisor uint64, + arg_depositTxMaxFee uint64, + arg_depositRevealAheadPeriod uint32, blockNumber *big.Int, -) (contractReferences, error) { - var result contractReferences +) error { + var result interface{} = nil err := chainutil.CallAtBlock( - b.callerOptions.From, - blockNumber, - nil, + b.transactorOptions.From, + blockNumber, nil, b.contractABI, b.caller, b.errorResolver, b.contractAddress, - "contractReferences", + "updateDepositParameters", &result, + arg_depositDustThreshold, + arg_depositTreasuryFeeDivisor, + arg_depositTxMaxFee, + arg_depositRevealAheadPeriod, ) - return result, err + return err } -type depositParameters struct { - DepositDustThreshold uint64 - DepositTreasuryFeeDivisor uint64 - DepositTxMaxFee uint64 - DepositRevealAheadPeriod uint32 -} +func (b *Bridge) UpdateDepositParametersGasEstimate( + arg_depositDustThreshold uint64, + arg_depositTreasuryFeeDivisor uint64, + arg_depositTxMaxFee uint64, + arg_depositRevealAheadPeriod uint32, +) (uint64, error) { + var result uint64 -func (b *Bridge) DepositParameters() (depositParameters, error) { - result, err := b.contract.DepositParameters( - b.callerOptions, + result, err := chainutil.EstimateGas( + b.callerOptions.From, + b.contractAddress, + "updateDepositParameters", + b.contractABI, + b.transactor, + arg_depositDustThreshold, + arg_depositTreasuryFeeDivisor, + arg_depositTxMaxFee, + arg_depositRevealAheadPeriod, ) - if err != nil { - return result, b.errorResolver.ResolveError( - err, - b.callerOptions.From, - nil, - "depositParameters", - ) - } - return result, err } -func (b *Bridge) DepositParametersAtBlock( - blockNumber *big.Int, -) (depositParameters, error) { - var result depositParameters +// Transaction submission. +func (b *Bridge) UpdateFraudParameters( + arg_fraudChallengeDepositAmount *big.Int, + arg_fraudChallengeDefeatTimeout uint32, + arg_fraudSlashingAmount *big.Int, + arg_fraudNotifierRewardMultiplier uint32, - err := chainutil.CallAtBlock( - b.callerOptions.From, - blockNumber, - nil, - b.contractABI, - b.caller, - b.errorResolver, - b.contractAddress, - "depositParameters", - &result, + transactionOptions ...chainutil.TransactionOptions, +) (*types.Transaction, error) { + bLogger.Debug( + "submitting transaction updateFraudParameters", + " params: ", + fmt.Sprint( + arg_fraudChallengeDepositAmount, + arg_fraudChallengeDefeatTimeout, + arg_fraudSlashingAmount, + arg_fraudNotifierRewardMultiplier, + ), ) - return result, err -} + b.transactionMutex.Lock() + defer b.transactionMutex.Unlock() -func (b *Bridge) Deposits( - arg_depositKey *big.Int, -) (abi.DepositDepositRequest, error) { - result, err := b.contract.Deposits( - b.callerOptions, - arg_depositKey, - ) + // create a copy + transactorOptions := new(bind.TransactOpts) + *transactorOptions = *b.transactorOptions - if err != nil { - return result, b.errorResolver.ResolveError( - err, - b.callerOptions.From, - nil, - "deposits", - arg_depositKey, + if len(transactionOptions) > 1 { + return nil, fmt.Errorf( + "could not process multiple transaction options sets", ) + } else if len(transactionOptions) > 0 { + transactionOptions[0].Apply(transactorOptions) } - return result, err -} + nonce, err := b.nonceManager.CurrentNonce() + if err != nil { + return nil, fmt.Errorf("failed to retrieve account nonce: %v", err) + } -func (b *Bridge) DepositsAtBlock( - arg_depositKey *big.Int, - blockNumber *big.Int, -) (abi.DepositDepositRequest, error) { - var result abi.DepositDepositRequest + transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - err := chainutil.CallAtBlock( - b.callerOptions.From, - blockNumber, - nil, - b.contractABI, - b.caller, - b.errorResolver, - b.contractAddress, - "deposits", - &result, - arg_depositKey, - ) - - return result, err -} - -func (b *Bridge) FraudChallenges( - arg_challengeKey *big.Int, -) (abi.FraudFraudChallenge, error) { - result, err := b.contract.FraudChallenges( - b.callerOptions, - arg_challengeKey, + transaction, err := b.contract.UpdateFraudParameters( + transactorOptions, + arg_fraudChallengeDepositAmount, + arg_fraudChallengeDefeatTimeout, + arg_fraudSlashingAmount, + arg_fraudNotifierRewardMultiplier, ) - if err != nil { - return result, b.errorResolver.ResolveError( + return transaction, b.errorResolver.ResolveError( err, - b.callerOptions.From, + b.transactorOptions.From, nil, - "fraudChallenges", - arg_challengeKey, + "updateFraudParameters", + arg_fraudChallengeDepositAmount, + arg_fraudChallengeDefeatTimeout, + arg_fraudSlashingAmount, + arg_fraudNotifierRewardMultiplier, ) } - return result, err -} - -func (b *Bridge) FraudChallengesAtBlock( - arg_challengeKey *big.Int, - blockNumber *big.Int, -) (abi.FraudFraudChallenge, error) { - var result abi.FraudFraudChallenge - - err := chainutil.CallAtBlock( - b.callerOptions.From, - blockNumber, - nil, - b.contractABI, - b.caller, - b.errorResolver, - b.contractAddress, - "fraudChallenges", - &result, - arg_challengeKey, + bLogger.Infof( + "submitted transaction updateFraudParameters with id: [%s] and nonce [%v]", + transaction.Hash(), + transaction.Nonce(), ) - return result, err -} + go b.miningWaiter.ForceMining( + transaction, + transactorOptions, + func(newTransactorOptions *bind.TransactOpts) (*types.Transaction, error) { + // If original transactor options has a non-zero gas limit, that + // means the client code set it on their own. In that case, we + // should rewrite the gas limit from the original transaction + // for each resubmission. If the gas limit is not set by the client + // code, let the the submitter re-estimate the gas limit on each + // resubmission. + if transactorOptions.GasLimit != 0 { + newTransactorOptions.GasLimit = transactorOptions.GasLimit + } -type fraudParameters struct { - FraudChallengeDepositAmount *big.Int - FraudChallengeDefeatTimeout uint32 - FraudSlashingAmount *big.Int - FraudNotifierRewardMultiplier uint32 -} + transaction, err := b.contract.UpdateFraudParameters( + newTransactorOptions, + arg_fraudChallengeDepositAmount, + arg_fraudChallengeDefeatTimeout, + arg_fraudSlashingAmount, + arg_fraudNotifierRewardMultiplier, + ) + if err != nil { + return nil, b.errorResolver.ResolveError( + err, + b.transactorOptions.From, + nil, + "updateFraudParameters", + arg_fraudChallengeDepositAmount, + arg_fraudChallengeDefeatTimeout, + arg_fraudSlashingAmount, + arg_fraudNotifierRewardMultiplier, + ) + } -func (b *Bridge) FraudParameters() (fraudParameters, error) { - result, err := b.contract.FraudParameters( - b.callerOptions, + bLogger.Infof( + "submitted transaction updateFraudParameters with id: [%s] and nonce [%v]", + transaction.Hash(), + transaction.Nonce(), + ) + + return transaction, nil + }, ) - if err != nil { - return result, b.errorResolver.ResolveError( - err, - b.callerOptions.From, - nil, - "fraudParameters", - ) - } + b.nonceManager.IncrementNonce() - return result, err + return transaction, err } -func (b *Bridge) FraudParametersAtBlock( +// Non-mutating call, not a transaction submission. +func (b *Bridge) CallUpdateFraudParameters( + arg_fraudChallengeDepositAmount *big.Int, + arg_fraudChallengeDefeatTimeout uint32, + arg_fraudSlashingAmount *big.Int, + arg_fraudNotifierRewardMultiplier uint32, blockNumber *big.Int, -) (fraudParameters, error) { - var result fraudParameters +) error { + var result interface{} = nil err := chainutil.CallAtBlock( - b.callerOptions.From, - blockNumber, - nil, + b.transactorOptions.From, + blockNumber, nil, b.contractABI, b.caller, b.errorResolver, b.contractAddress, - "fraudParameters", + "updateFraudParameters", &result, + arg_fraudChallengeDepositAmount, + arg_fraudChallengeDefeatTimeout, + arg_fraudSlashingAmount, + arg_fraudNotifierRewardMultiplier, ) - return result, err -} - -func (b *Bridge) GetRebateStaking() (common.Address, error) { - result, err := b.contract.GetRebateStaking( - b.callerOptions, - ) - - if err != nil { - return result, b.errorResolver.ResolveError( - err, - b.callerOptions.From, - nil, - "getRebateStaking", - ) - } - - return result, err + return err } -func (b *Bridge) GetRebateStakingAtBlock( - blockNumber *big.Int, -) (common.Address, error) { - var result common.Address +func (b *Bridge) UpdateFraudParametersGasEstimate( + arg_fraudChallengeDepositAmount *big.Int, + arg_fraudChallengeDefeatTimeout uint32, + arg_fraudSlashingAmount *big.Int, + arg_fraudNotifierRewardMultiplier uint32, +) (uint64, error) { + var result uint64 - err := chainutil.CallAtBlock( + result, err := chainutil.EstimateGas( b.callerOptions.From, - blockNumber, - nil, - b.contractABI, - b.caller, - b.errorResolver, b.contractAddress, - "getRebateStaking", - &result, + "updateFraudParameters", + b.contractABI, + b.transactor, + arg_fraudChallengeDepositAmount, + arg_fraudChallengeDefeatTimeout, + arg_fraudSlashingAmount, + arg_fraudNotifierRewardMultiplier, ) return result, err } -func (b *Bridge) GetRedemptionWatchtower() (common.Address, error) { - result, err := b.contract.GetRedemptionWatchtower( - b.callerOptions, +// Transaction submission. +func (b *Bridge) UpdateMovingFundsParameters( + arg_movingFundsTxMaxTotalFee uint64, + arg_movingFundsDustThreshold uint64, + arg_movingFundsTimeoutResetDelay uint32, + arg_movingFundsTimeout uint32, + arg_movingFundsTimeoutSlashingAmount *big.Int, + arg_movingFundsTimeoutNotifierRewardMultiplier uint32, + arg_movingFundsCommitmentGasOffset uint16, + arg_movedFundsSweepTxMaxTotalFee uint64, + arg_movedFundsSweepTimeout uint32, + arg_movedFundsSweepTimeoutSlashingAmount *big.Int, + arg_movedFundsSweepTimeoutNotifierRewardMultiplier uint32, + + transactionOptions ...chainutil.TransactionOptions, +) (*types.Transaction, error) { + bLogger.Debug( + "submitting transaction updateMovingFundsParameters", + " params: ", + fmt.Sprint( + arg_movingFundsTxMaxTotalFee, + arg_movingFundsDustThreshold, + arg_movingFundsTimeoutResetDelay, + arg_movingFundsTimeout, + arg_movingFundsTimeoutSlashingAmount, + arg_movingFundsTimeoutNotifierRewardMultiplier, + arg_movingFundsCommitmentGasOffset, + arg_movedFundsSweepTxMaxTotalFee, + arg_movedFundsSweepTimeout, + arg_movedFundsSweepTimeoutSlashingAmount, + arg_movedFundsSweepTimeoutNotifierRewardMultiplier, + ), ) - if err != nil { - return result, b.errorResolver.ResolveError( - err, - b.callerOptions.From, - nil, - "getRedemptionWatchtower", + b.transactionMutex.Lock() + defer b.transactionMutex.Unlock() + + // create a copy + transactorOptions := new(bind.TransactOpts) + *transactorOptions = *b.transactorOptions + + if len(transactionOptions) > 1 { + return nil, fmt.Errorf( + "could not process multiple transaction options sets", ) + } else if len(transactionOptions) > 0 { + transactionOptions[0].Apply(transactorOptions) } - return result, err -} - -func (b *Bridge) GetRedemptionWatchtowerAtBlock( - blockNumber *big.Int, -) (common.Address, error) { - var result common.Address + nonce, err := b.nonceManager.CurrentNonce() + if err != nil { + return nil, fmt.Errorf("failed to retrieve account nonce: %v", err) + } - err := chainutil.CallAtBlock( - b.callerOptions.From, - blockNumber, - nil, - b.contractABI, - b.caller, - b.errorResolver, - b.contractAddress, - "getRedemptionWatchtower", - &result, - ) + transactorOptions.Nonce = new(big.Int).SetUint64(nonce) - return result, err -} - -func (b *Bridge) Governance() (common.Address, error) { - result, err := b.contract.Governance( - b.callerOptions, + transaction, err := b.contract.UpdateMovingFundsParameters( + transactorOptions, + arg_movingFundsTxMaxTotalFee, + arg_movingFundsDustThreshold, + arg_movingFundsTimeoutResetDelay, + arg_movingFundsTimeout, + arg_movingFundsTimeoutSlashingAmount, + arg_movingFundsTimeoutNotifierRewardMultiplier, + arg_movingFundsCommitmentGasOffset, + arg_movedFundsSweepTxMaxTotalFee, + arg_movedFundsSweepTimeout, + arg_movedFundsSweepTimeoutSlashingAmount, + arg_movedFundsSweepTimeoutNotifierRewardMultiplier, ) - if err != nil { - return result, b.errorResolver.ResolveError( + return transaction, b.errorResolver.ResolveError( err, - b.callerOptions.From, + b.transactorOptions.From, nil, - "governance", + "updateMovingFundsParameters", + arg_movingFundsTxMaxTotalFee, + arg_movingFundsDustThreshold, + arg_movingFundsTimeoutResetDelay, + arg_movingFundsTimeout, + arg_movingFundsTimeoutSlashingAmount, + arg_movingFundsTimeoutNotifierRewardMultiplier, + arg_movingFundsCommitmentGasOffset, + arg_movedFundsSweepTxMaxTotalFee, + arg_movedFundsSweepTimeout, + arg_movedFundsSweepTimeoutSlashingAmount, + arg_movedFundsSweepTimeoutNotifierRewardMultiplier, ) } - return result, err -} + bLogger.Infof( + "submitted transaction updateMovingFundsParameters with id: [%s] and nonce [%v]", + transaction.Hash(), + transaction.Nonce(), + ) -func (b *Bridge) GovernanceAtBlock( - blockNumber *big.Int, -) (common.Address, error) { - var result common.Address + go b.miningWaiter.ForceMining( + transaction, + transactorOptions, + func(newTransactorOptions *bind.TransactOpts) (*types.Transaction, error) { + // If original transactor options has a non-zero gas limit, that + // means the client code set it on their own. In that case, we + // should rewrite the gas limit from the original transaction + // for each resubmission. If the gas limit is not set by the client + // code, let the the submitter re-estimate the gas limit on each + // resubmission. + if transactorOptions.GasLimit != 0 { + newTransactorOptions.GasLimit = transactorOptions.GasLimit + } - err := chainutil.CallAtBlock( - b.callerOptions.From, - blockNumber, - nil, - b.contractABI, - b.caller, - b.errorResolver, - b.contractAddress, - "governance", - &result, - ) + transaction, err := b.contract.UpdateMovingFundsParameters( + newTransactorOptions, + arg_movingFundsTxMaxTotalFee, + arg_movingFundsDustThreshold, + arg_movingFundsTimeoutResetDelay, + arg_movingFundsTimeout, + arg_movingFundsTimeoutSlashingAmount, + arg_movingFundsTimeoutNotifierRewardMultiplier, + arg_movingFundsCommitmentGasOffset, + arg_movedFundsSweepTxMaxTotalFee, + arg_movedFundsSweepTimeout, + arg_movedFundsSweepTimeoutSlashingAmount, + arg_movedFundsSweepTimeoutNotifierRewardMultiplier, + ) + if err != nil { + return nil, b.errorResolver.ResolveError( + err, + b.transactorOptions.From, + nil, + "updateMovingFundsParameters", + arg_movingFundsTxMaxTotalFee, + arg_movingFundsDustThreshold, + arg_movingFundsTimeoutResetDelay, + arg_movingFundsTimeout, + arg_movingFundsTimeoutSlashingAmount, + arg_movingFundsTimeoutNotifierRewardMultiplier, + arg_movingFundsCommitmentGasOffset, + arg_movedFundsSweepTxMaxTotalFee, + arg_movedFundsSweepTimeout, + arg_movedFundsSweepTimeoutSlashingAmount, + arg_movedFundsSweepTimeoutNotifierRewardMultiplier, + ) + } - return result, err -} + bLogger.Infof( + "submitted transaction updateMovingFundsParameters with id: [%s] and nonce [%v]", + transaction.Hash(), + transaction.Nonce(), + ) -func (b *Bridge) IsVaultTrusted( - arg_vault common.Address, -) (bool, error) { - result, err := b.contract.IsVaultTrusted( - b.callerOptions, - arg_vault, + return transaction, nil + }, ) - if err != nil { - return result, b.errorResolver.ResolveError( - err, - b.callerOptions.From, - nil, - "isVaultTrusted", - arg_vault, - ) - } + b.nonceManager.IncrementNonce() - return result, err + return transaction, err } -func (b *Bridge) IsVaultTrustedAtBlock( - arg_vault common.Address, +// Non-mutating call, not a transaction submission. +func (b *Bridge) CallUpdateMovingFundsParameters( + arg_movingFundsTxMaxTotalFee uint64, + arg_movingFundsDustThreshold uint64, + arg_movingFundsTimeoutResetDelay uint32, + arg_movingFundsTimeout uint32, + arg_movingFundsTimeoutSlashingAmount *big.Int, + arg_movingFundsTimeoutNotifierRewardMultiplier uint32, + arg_movingFundsCommitmentGasOffset uint16, + arg_movedFundsSweepTxMaxTotalFee uint64, + arg_movedFundsSweepTimeout uint32, + arg_movedFundsSweepTimeoutSlashingAmount *big.Int, + arg_movedFundsSweepTimeoutNotifierRewardMultiplier uint32, blockNumber *big.Int, -) (bool, error) { - var result bool +) error { + var result interface{} = nil err := chainutil.CallAtBlock( - b.callerOptions.From, - blockNumber, - nil, + b.transactorOptions.From, + blockNumber, nil, b.contractABI, b.caller, b.errorResolver, b.contractAddress, - "isVaultTrusted", + "updateMovingFundsParameters", &result, - arg_vault, - ) - - return result, err -} - -func (b *Bridge) LiveWalletsCount() (uint32, error) { - result, err := b.contract.LiveWalletsCount( - b.callerOptions, + arg_movingFundsTxMaxTotalFee, + arg_movingFundsDustThreshold, + arg_movingFundsTimeoutResetDelay, + arg_movingFundsTimeout, + arg_movingFundsTimeoutSlashingAmount, + arg_movingFundsTimeoutNotifierRewardMultiplier, + arg_movingFundsCommitmentGasOffset, + arg_movedFundsSweepTxMaxTotalFee, + arg_movedFundsSweepTimeout, + arg_movedFundsSweepTimeoutSlashingAmount, + arg_movedFundsSweepTimeoutNotifierRewardMultiplier, ) - if err != nil { - return result, b.errorResolver.ResolveError( - err, - b.callerOptions.From, - nil, - "liveWalletsCount", - ) - } - - return result, err + return err } -func (b *Bridge) LiveWalletsCountAtBlock( - blockNumber *big.Int, -) (uint32, error) { - var result uint32 +func (b *Bridge) UpdateMovingFundsParametersGasEstimate( + arg_movingFundsTxMaxTotalFee uint64, + arg_movingFundsDustThreshold uint64, + arg_movingFundsTimeoutResetDelay uint32, + arg_movingFundsTimeout uint32, + arg_movingFundsTimeoutSlashingAmount *big.Int, + arg_movingFundsTimeoutNotifierRewardMultiplier uint32, + arg_movingFundsCommitmentGasOffset uint16, + arg_movedFundsSweepTxMaxTotalFee uint64, + arg_movedFundsSweepTimeout uint32, + arg_movedFundsSweepTimeoutSlashingAmount *big.Int, + arg_movedFundsSweepTimeoutNotifierRewardMultiplier uint32, +) (uint64, error) { + var result uint64 - err := chainutil.CallAtBlock( + result, err := chainutil.EstimateGas( b.callerOptions.From, - blockNumber, - nil, - b.contractABI, - b.caller, - b.errorResolver, b.contractAddress, - "liveWalletsCount", - &result, + "updateMovingFundsParameters", + b.contractABI, + b.transactor, + arg_movingFundsTxMaxTotalFee, + arg_movingFundsDustThreshold, + arg_movingFundsTimeoutResetDelay, + arg_movingFundsTimeout, + arg_movingFundsTimeoutSlashingAmount, + arg_movingFundsTimeoutNotifierRewardMultiplier, + arg_movingFundsCommitmentGasOffset, + arg_movedFundsSweepTxMaxTotalFee, + arg_movedFundsSweepTimeout, + arg_movedFundsSweepTimeoutSlashingAmount, + arg_movedFundsSweepTimeoutNotifierRewardMultiplier, ) return result, err } -func (b *Bridge) MovedFundsSweepRequests( - arg_requestKey *big.Int, -) (abi.MovingFundsMovedFundsSweepRequest, error) { - result, err := b.contract.MovedFundsSweepRequests( - b.callerOptions, - arg_requestKey, - ) - - if err != nil { - return result, b.errorResolver.ResolveError( - err, - b.callerOptions.From, - nil, - "movedFundsSweepRequests", - arg_requestKey, - ) - } +// Transaction submission. +func (b *Bridge) UpdateRedemptionParameters( + arg_redemptionDustThreshold uint64, + arg_redemptionTreasuryFeeDivisor uint64, + arg_redemptionTxMaxFee uint64, + arg_redemptionTxMaxTotalFee uint64, + arg_redemptionTimeout uint32, + arg_redemptionTimeoutSlashingAmount *big.Int, + arg_redemptionTimeoutNotifierRewardMultiplier uint32, - return result, err -} + transactionOptions ...chainutil.TransactionOptions, +) (*types.Transaction, error) { + bLogger.Debug( + "submitting transaction updateRedemptionParameters", + " params: ", + fmt.Sprint( + arg_redemptionDustThreshold, + arg_redemptionTreasuryFeeDivisor, + arg_redemptionTxMaxFee, + arg_redemptionTxMaxTotalFee, + arg_redemptionTimeout, + arg_redemptionTimeoutSlashingAmount, + arg_redemptionTimeoutNotifierRewardMultiplier, + ), + ) -func (b *Bridge) MovedFundsSweepRequestsAtBlock( - arg_requestKey *big.Int, - blockNumber *big.Int, -) (abi.MovingFundsMovedFundsSweepRequest, error) { - var result abi.MovingFundsMovedFundsSweepRequest + b.transactionMutex.Lock() + defer b.transactionMutex.Unlock() - err := chainutil.CallAtBlock( - b.callerOptions.From, - blockNumber, - nil, - b.contractABI, - b.caller, - b.errorResolver, - b.contractAddress, - "movedFundsSweepRequests", - &result, - arg_requestKey, - ) + // create a copy + transactorOptions := new(bind.TransactOpts) + *transactorOptions = *b.transactorOptions - return result, err -} + if len(transactionOptions) > 1 { + return nil, fmt.Errorf( + "could not process multiple transaction options sets", + ) + } else if len(transactionOptions) > 0 { + transactionOptions[0].Apply(transactorOptions) + } -type movingFundsParameters struct { - MovingFundsTxMaxTotalFee uint64 - MovingFundsDustThreshold uint64 - MovingFundsTimeoutResetDelay uint32 - MovingFundsTimeout uint32 - MovingFundsTimeoutSlashingAmount *big.Int - MovingFundsTimeoutNotifierRewardMultiplier uint32 - MovingFundsCommitmentGasOffset uint16 - MovedFundsSweepTxMaxTotalFee uint64 - MovedFundsSweepTimeout uint32 - MovedFundsSweepTimeoutSlashingAmount *big.Int - MovedFundsSweepTimeoutNotifierRewardMultiplier uint32 -} + nonce, err := b.nonceManager.CurrentNonce() + if err != nil { + return nil, fmt.Errorf("failed to retrieve account nonce: %v", err) + } -func (b *Bridge) MovingFundsParameters() (movingFundsParameters, error) { - result, err := b.contract.MovingFundsParameters( - b.callerOptions, - ) + transactorOptions.Nonce = new(big.Int).SetUint64(nonce) + transaction, err := b.contract.UpdateRedemptionParameters( + transactorOptions, + arg_redemptionDustThreshold, + arg_redemptionTreasuryFeeDivisor, + arg_redemptionTxMaxFee, + arg_redemptionTxMaxTotalFee, + arg_redemptionTimeout, + arg_redemptionTimeoutSlashingAmount, + arg_redemptionTimeoutNotifierRewardMultiplier, + ) if err != nil { - return result, b.errorResolver.ResolveError( + return transaction, b.errorResolver.ResolveError( err, - b.callerOptions.From, + b.transactorOptions.From, nil, - "movingFundsParameters", + "updateRedemptionParameters", + arg_redemptionDustThreshold, + arg_redemptionTreasuryFeeDivisor, + arg_redemptionTxMaxFee, + arg_redemptionTxMaxTotalFee, + arg_redemptionTimeout, + arg_redemptionTimeoutSlashingAmount, + arg_redemptionTimeoutNotifierRewardMultiplier, ) } - return result, err -} + bLogger.Infof( + "submitted transaction updateRedemptionParameters with id: [%s] and nonce [%v]", + transaction.Hash(), + transaction.Nonce(), + ) -func (b *Bridge) MovingFundsParametersAtBlock( - blockNumber *big.Int, -) (movingFundsParameters, error) { - var result movingFundsParameters + go b.miningWaiter.ForceMining( + transaction, + transactorOptions, + func(newTransactorOptions *bind.TransactOpts) (*types.Transaction, error) { + // If original transactor options has a non-zero gas limit, that + // means the client code set it on their own. In that case, we + // should rewrite the gas limit from the original transaction + // for each resubmission. If the gas limit is not set by the client + // code, let the the submitter re-estimate the gas limit on each + // resubmission. + if transactorOptions.GasLimit != 0 { + newTransactorOptions.GasLimit = transactorOptions.GasLimit + } - err := chainutil.CallAtBlock( - b.callerOptions.From, - blockNumber, - nil, - b.contractABI, - b.caller, - b.errorResolver, - b.contractAddress, - "movingFundsParameters", - &result, - ) + transaction, err := b.contract.UpdateRedemptionParameters( + newTransactorOptions, + arg_redemptionDustThreshold, + arg_redemptionTreasuryFeeDivisor, + arg_redemptionTxMaxFee, + arg_redemptionTxMaxTotalFee, + arg_redemptionTimeout, + arg_redemptionTimeoutSlashingAmount, + arg_redemptionTimeoutNotifierRewardMultiplier, + ) + if err != nil { + return nil, b.errorResolver.ResolveError( + err, + b.transactorOptions.From, + nil, + "updateRedemptionParameters", + arg_redemptionDustThreshold, + arg_redemptionTreasuryFeeDivisor, + arg_redemptionTxMaxFee, + arg_redemptionTxMaxTotalFee, + arg_redemptionTimeout, + arg_redemptionTimeoutSlashingAmount, + arg_redemptionTimeoutNotifierRewardMultiplier, + ) + } - return result, err -} + bLogger.Infof( + "submitted transaction updateRedemptionParameters with id: [%s] and nonce [%v]", + transaction.Hash(), + transaction.Nonce(), + ) -func (b *Bridge) PendingRedemptions( - arg_redemptionKey *big.Int, -) (abi.RedemptionRedemptionRequest, error) { - result, err := b.contract.PendingRedemptions( - b.callerOptions, - arg_redemptionKey, + return transaction, nil + }, ) - if err != nil { - return result, b.errorResolver.ResolveError( - err, - b.callerOptions.From, - nil, - "pendingRedemptions", - arg_redemptionKey, - ) - } + b.nonceManager.IncrementNonce() - return result, err + return transaction, err } -func (b *Bridge) PendingRedemptionsAtBlock( - arg_redemptionKey *big.Int, +// Non-mutating call, not a transaction submission. +func (b *Bridge) CallUpdateRedemptionParameters( + arg_redemptionDustThreshold uint64, + arg_redemptionTreasuryFeeDivisor uint64, + arg_redemptionTxMaxFee uint64, + arg_redemptionTxMaxTotalFee uint64, + arg_redemptionTimeout uint32, + arg_redemptionTimeoutSlashingAmount *big.Int, + arg_redemptionTimeoutNotifierRewardMultiplier uint32, blockNumber *big.Int, -) (abi.RedemptionRedemptionRequest, error) { - var result abi.RedemptionRedemptionRequest +) error { + var result interface{} = nil err := chainutil.CallAtBlock( - b.callerOptions.From, - blockNumber, - nil, + b.transactorOptions.From, + blockNumber, nil, b.contractABI, b.caller, b.errorResolver, b.contractAddress, - "pendingRedemptions", + "updateRedemptionParameters", &result, - arg_redemptionKey, + arg_redemptionDustThreshold, + arg_redemptionTreasuryFeeDivisor, + arg_redemptionTxMaxFee, + arg_redemptionTxMaxTotalFee, + arg_redemptionTimeout, + arg_redemptionTimeoutSlashingAmount, + arg_redemptionTimeoutNotifierRewardMultiplier, ) - return result, err + return err } -type redemptionParameters struct { - RedemptionDustThreshold uint64 - RedemptionTreasuryFeeDivisor uint64 - RedemptionTxMaxFee uint64 - RedemptionTxMaxTotalFee uint64 - RedemptionTimeout uint32 - RedemptionTimeoutSlashingAmount *big.Int - RedemptionTimeoutNotifierRewardMultiplier uint32 -} +func (b *Bridge) UpdateRedemptionParametersGasEstimate( + arg_redemptionDustThreshold uint64, + arg_redemptionTreasuryFeeDivisor uint64, + arg_redemptionTxMaxFee uint64, + arg_redemptionTxMaxTotalFee uint64, + arg_redemptionTimeout uint32, + arg_redemptionTimeoutSlashingAmount *big.Int, + arg_redemptionTimeoutNotifierRewardMultiplier uint32, +) (uint64, error) { + var result uint64 -func (b *Bridge) RedemptionParameters() (redemptionParameters, error) { - result, err := b.contract.RedemptionParameters( - b.callerOptions, + result, err := chainutil.EstimateGas( + b.callerOptions.From, + b.contractAddress, + "updateRedemptionParameters", + b.contractABI, + b.transactor, + arg_redemptionDustThreshold, + arg_redemptionTreasuryFeeDivisor, + arg_redemptionTxMaxFee, + arg_redemptionTxMaxTotalFee, + arg_redemptionTimeout, + arg_redemptionTimeoutSlashingAmount, + arg_redemptionTimeoutNotifierRewardMultiplier, ) - if err != nil { - return result, b.errorResolver.ResolveError( - err, - b.callerOptions.From, - nil, - "redemptionParameters", - ) - } - return result, err } -func (b *Bridge) RedemptionParametersAtBlock( - blockNumber *big.Int, -) (redemptionParameters, error) { - var result redemptionParameters +// Transaction submission. +func (b *Bridge) UpdateTreasury( + arg_treasury common.Address, - err := chainutil.CallAtBlock( - b.callerOptions.From, - blockNumber, - nil, - b.contractABI, - b.caller, - b.errorResolver, - b.contractAddress, - "redemptionParameters", - &result, + transactionOptions ...chainutil.TransactionOptions, +) (*types.Transaction, error) { + bLogger.Debug( + "submitting transaction updateTreasury", + " params: ", + fmt.Sprint( + arg_treasury, + ), ) - return result, err -} + b.transactionMutex.Lock() + defer b.transactionMutex.Unlock() -func (b *Bridge) SpentMainUTXOs( - arg_utxoKey *big.Int, -) (bool, error) { - result, err := b.contract.SpentMainUTXOs( - b.callerOptions, - arg_utxoKey, - ) + // create a copy + transactorOptions := new(bind.TransactOpts) + *transactorOptions = *b.transactorOptions - if err != nil { - return result, b.errorResolver.ResolveError( - err, - b.callerOptions.From, - nil, - "spentMainUTXOs", - arg_utxoKey, + if len(transactionOptions) > 1 { + return nil, fmt.Errorf( + "could not process multiple transaction options sets", ) + } else if len(transactionOptions) > 0 { + transactionOptions[0].Apply(transactorOptions) } - return result, err -} - -func (b *Bridge) SpentMainUTXOsAtBlock( - arg_utxoKey *big.Int, - blockNumber *big.Int, -) (bool, error) { - var result bool - - err := chainutil.CallAtBlock( - b.callerOptions.From, - blockNumber, - nil, - b.contractABI, - b.caller, - b.errorResolver, - b.contractAddress, - "spentMainUTXOs", - &result, - arg_utxoKey, - ) + nonce, err := b.nonceManager.CurrentNonce() + if err != nil { + return nil, fmt.Errorf("failed to retrieve account nonce: %v", err) + } - return result, err -} + transactorOptions.Nonce = new(big.Int).SetUint64(nonce) -func (b *Bridge) TimedOutRedemptions( - arg_redemptionKey *big.Int, -) (abi.RedemptionRedemptionRequest, error) { - result, err := b.contract.TimedOutRedemptions( - b.callerOptions, - arg_redemptionKey, + transaction, err := b.contract.UpdateTreasury( + transactorOptions, + arg_treasury, ) - if err != nil { - return result, b.errorResolver.ResolveError( + return transaction, b.errorResolver.ResolveError( err, - b.callerOptions.From, + b.transactorOptions.From, nil, - "timedOutRedemptions", - arg_redemptionKey, + "updateTreasury", + arg_treasury, ) } - return result, err -} + bLogger.Infof( + "submitted transaction updateTreasury with id: [%s] and nonce [%v]", + transaction.Hash(), + transaction.Nonce(), + ) -func (b *Bridge) TimedOutRedemptionsAtBlock( - arg_redemptionKey *big.Int, - blockNumber *big.Int, -) (abi.RedemptionRedemptionRequest, error) { - var result abi.RedemptionRedemptionRequest + go b.miningWaiter.ForceMining( + transaction, + transactorOptions, + func(newTransactorOptions *bind.TransactOpts) (*types.Transaction, error) { + // If original transactor options has a non-zero gas limit, that + // means the client code set it on their own. In that case, we + // should rewrite the gas limit from the original transaction + // for each resubmission. If the gas limit is not set by the client + // code, let the the submitter re-estimate the gas limit on each + // resubmission. + if transactorOptions.GasLimit != 0 { + newTransactorOptions.GasLimit = transactorOptions.GasLimit + } - err := chainutil.CallAtBlock( - b.callerOptions.From, - blockNumber, - nil, - b.contractABI, - b.caller, - b.errorResolver, - b.contractAddress, - "timedOutRedemptions", - &result, - arg_redemptionKey, - ) + transaction, err := b.contract.UpdateTreasury( + newTransactorOptions, + arg_treasury, + ) + if err != nil { + return nil, b.errorResolver.ResolveError( + err, + b.transactorOptions.From, + nil, + "updateTreasury", + arg_treasury, + ) + } - return result, err -} + bLogger.Infof( + "submitted transaction updateTreasury with id: [%s] and nonce [%v]", + transaction.Hash(), + transaction.Nonce(), + ) -func (b *Bridge) Treasury() (common.Address, error) { - result, err := b.contract.Treasury( - b.callerOptions, + return transaction, nil + }, ) - if err != nil { - return result, b.errorResolver.ResolveError( - err, - b.callerOptions.From, - nil, - "treasury", - ) - } + b.nonceManager.IncrementNonce() - return result, err + return transaction, err } -func (b *Bridge) TreasuryAtBlock( +// Non-mutating call, not a transaction submission. +func (b *Bridge) CallUpdateTreasury( + arg_treasury common.Address, blockNumber *big.Int, -) (common.Address, error) { - var result common.Address +) error { + var result interface{} = nil err := chainutil.CallAtBlock( - b.callerOptions.From, - blockNumber, - nil, + b.transactorOptions.From, + blockNumber, nil, b.contractABI, b.caller, b.errorResolver, b.contractAddress, - "treasury", + "updateTreasury", &result, + arg_treasury, ) - return result, err -} - -func (b *Bridge) TxProofDifficultyFactor() (*big.Int, error) { - result, err := b.contract.TxProofDifficultyFactor( - b.callerOptions, - ) - - if err != nil { - return result, b.errorResolver.ResolveError( - err, - b.callerOptions.From, - nil, - "txProofDifficultyFactor", - ) - } - - return result, err + return err } -func (b *Bridge) TxProofDifficultyFactorAtBlock( - blockNumber *big.Int, -) (*big.Int, error) { - var result *big.Int +func (b *Bridge) UpdateTreasuryGasEstimate( + arg_treasury common.Address, +) (uint64, error) { + var result uint64 - err := chainutil.CallAtBlock( + result, err := chainutil.EstimateGas( b.callerOptions.From, - blockNumber, - nil, - b.contractABI, - b.caller, - b.errorResolver, b.contractAddress, - "txProofDifficultyFactor", - &result, + "updateTreasury", + b.contractABI, + b.transactor, + arg_treasury, ) return result, err } -func (b *Bridge) WalletID( - arg_walletPubKeyHash [20]byte, -) ([32]byte, error) { - result, err := b.contract.WalletID( - b.callerOptions, - arg_walletPubKeyHash, +// Transaction submission. +func (b *Bridge) UpdateWalletParameters( + arg_walletCreationPeriod uint32, + arg_walletCreationMinBtcBalance uint64, + arg_walletCreationMaxBtcBalance uint64, + arg_walletClosureMinBtcBalance uint64, + arg_walletMaxAge uint32, + arg_walletMaxBtcTransfer uint64, + arg_walletClosingPeriod uint32, + + transactionOptions ...chainutil.TransactionOptions, +) (*types.Transaction, error) { + bLogger.Debug( + "submitting transaction updateWalletParameters", + " params: ", + fmt.Sprint( + arg_walletCreationPeriod, + arg_walletCreationMinBtcBalance, + arg_walletCreationMaxBtcBalance, + arg_walletClosureMinBtcBalance, + arg_walletMaxAge, + arg_walletMaxBtcTransfer, + arg_walletClosingPeriod, + ), ) - if err != nil { - return result, b.errorResolver.ResolveError( + b.transactionMutex.Lock() + defer b.transactionMutex.Unlock() + + // create a copy + transactorOptions := new(bind.TransactOpts) + *transactorOptions = *b.transactorOptions + + if len(transactionOptions) > 1 { + return nil, fmt.Errorf( + "could not process multiple transaction options sets", + ) + } else if len(transactionOptions) > 0 { + transactionOptions[0].Apply(transactorOptions) + } + + nonce, err := b.nonceManager.CurrentNonce() + if err != nil { + return nil, fmt.Errorf("failed to retrieve account nonce: %v", err) + } + + transactorOptions.Nonce = new(big.Int).SetUint64(nonce) + + transaction, err := b.contract.UpdateWalletParameters( + transactorOptions, + arg_walletCreationPeriod, + arg_walletCreationMinBtcBalance, + arg_walletCreationMaxBtcBalance, + arg_walletClosureMinBtcBalance, + arg_walletMaxAge, + arg_walletMaxBtcTransfer, + arg_walletClosingPeriod, + ) + if err != nil { + return transaction, b.errorResolver.ResolveError( err, - b.callerOptions.From, + b.transactorOptions.From, nil, - "walletID", - arg_walletPubKeyHash, + "updateWalletParameters", + arg_walletCreationPeriod, + arg_walletCreationMinBtcBalance, + arg_walletCreationMaxBtcBalance, + arg_walletClosureMinBtcBalance, + arg_walletMaxAge, + arg_walletMaxBtcTransfer, + arg_walletClosingPeriod, ) } - return result, err + bLogger.Infof( + "submitted transaction updateWalletParameters with id: [%s] and nonce [%v]", + transaction.Hash(), + transaction.Nonce(), + ) + + go b.miningWaiter.ForceMining( + transaction, + transactorOptions, + func(newTransactorOptions *bind.TransactOpts) (*types.Transaction, error) { + // If original transactor options has a non-zero gas limit, that + // means the client code set it on their own. In that case, we + // should rewrite the gas limit from the original transaction + // for each resubmission. If the gas limit is not set by the client + // code, let the the submitter re-estimate the gas limit on each + // resubmission. + if transactorOptions.GasLimit != 0 { + newTransactorOptions.GasLimit = transactorOptions.GasLimit + } + + transaction, err := b.contract.UpdateWalletParameters( + newTransactorOptions, + arg_walletCreationPeriod, + arg_walletCreationMinBtcBalance, + arg_walletCreationMaxBtcBalance, + arg_walletClosureMinBtcBalance, + arg_walletMaxAge, + arg_walletMaxBtcTransfer, + arg_walletClosingPeriod, + ) + if err != nil { + return nil, b.errorResolver.ResolveError( + err, + b.transactorOptions.From, + nil, + "updateWalletParameters", + arg_walletCreationPeriod, + arg_walletCreationMinBtcBalance, + arg_walletCreationMaxBtcBalance, + arg_walletClosureMinBtcBalance, + arg_walletMaxAge, + arg_walletMaxBtcTransfer, + arg_walletClosingPeriod, + ) + } + + bLogger.Infof( + "submitted transaction updateWalletParameters with id: [%s] and nonce [%v]", + transaction.Hash(), + transaction.Nonce(), + ) + + return transaction, nil + }, + ) + + b.nonceManager.IncrementNonce() + + return transaction, err } -func (b *Bridge) WalletIDAtBlock( - arg_walletPubKeyHash [20]byte, +// Non-mutating call, not a transaction submission. +func (b *Bridge) CallUpdateWalletParameters( + arg_walletCreationPeriod uint32, + arg_walletCreationMinBtcBalance uint64, + arg_walletCreationMaxBtcBalance uint64, + arg_walletClosureMinBtcBalance uint64, + arg_walletMaxAge uint32, + arg_walletMaxBtcTransfer uint64, + arg_walletClosingPeriod uint32, blockNumber *big.Int, -) ([32]byte, error) { - var result [32]byte +) error { + var result interface{} = nil err := chainutil.CallAtBlock( - b.callerOptions.From, - blockNumber, - nil, + b.transactorOptions.From, + blockNumber, nil, b.contractABI, b.caller, b.errorResolver, b.contractAddress, - "walletID", + "updateWalletParameters", &result, - arg_walletPubKeyHash, + arg_walletCreationPeriod, + arg_walletCreationMinBtcBalance, + arg_walletCreationMaxBtcBalance, + arg_walletClosureMinBtcBalance, + arg_walletMaxAge, + arg_walletMaxBtcTransfer, + arg_walletClosingPeriod, ) - return result, err + return err } -type walletParameters struct { - WalletCreationPeriod uint32 - WalletCreationMinBtcBalance uint64 - WalletCreationMaxBtcBalance uint64 - WalletClosureMinBtcBalance uint64 - WalletMaxAge uint32 - WalletMaxBtcTransfer uint64 - WalletClosingPeriod uint32 +func (b *Bridge) UpdateWalletParametersGasEstimate( + arg_walletCreationPeriod uint32, + arg_walletCreationMinBtcBalance uint64, + arg_walletCreationMaxBtcBalance uint64, + arg_walletClosureMinBtcBalance uint64, + arg_walletMaxAge uint32, + arg_walletMaxBtcTransfer uint64, + arg_walletClosingPeriod uint32, +) (uint64, error) { + var result uint64 + + result, err := chainutil.EstimateGas( + b.callerOptions.From, + b.contractAddress, + "updateWalletParameters", + b.contractABI, + b.transactor, + arg_walletCreationPeriod, + arg_walletCreationMinBtcBalance, + arg_walletCreationMaxBtcBalance, + arg_walletClosureMinBtcBalance, + arg_walletMaxAge, + arg_walletMaxBtcTransfer, + arg_walletClosingPeriod, + ) + + return result, err } -func (b *Bridge) WalletParameters() (walletParameters, error) { - result, err := b.contract.WalletParameters( +// ----- Const Methods ------ + +func (b *Bridge) ActiveWalletID() ([32]byte, error) { + result, err := b.contract.ActiveWalletID( b.callerOptions, ) @@ -6858,17 +6782,17 @@ func (b *Bridge) WalletParameters() (walletParameters, error) { err, b.callerOptions.From, nil, - "walletParameters", + "activeWalletID", ) } return result, err } -func (b *Bridge) WalletParametersAtBlock( +func (b *Bridge) ActiveWalletIDAtBlock( blockNumber *big.Int, -) (walletParameters, error) { - var result walletParameters +) ([32]byte, error) { + var result [32]byte err := chainutil.CallAtBlock( b.callerOptions.From, @@ -6878,19 +6802,16 @@ func (b *Bridge) WalletParametersAtBlock( b.caller, b.errorResolver, b.contractAddress, - "walletParameters", + "activeWalletID", &result, ) return result, err } -func (b *Bridge) WalletPubKeyHashForWalletID( - arg_walletId [32]byte, -) ([20]byte, error) { - result, err := b.contract.WalletPubKeyHashForWalletID( +func (b *Bridge) ActiveWalletPubKeyHash() ([20]byte, error) { + result, err := b.contract.ActiveWalletPubKeyHash( b.callerOptions, - arg_walletId, ) if err != nil { @@ -6898,16 +6819,14 @@ func (b *Bridge) WalletPubKeyHashForWalletID( err, b.callerOptions.From, nil, - "walletPubKeyHashForWalletID", - arg_walletId, + "activeWalletPubKeyHash", ) } return result, err } -func (b *Bridge) WalletPubKeyHashForWalletIDAtBlock( - arg_walletId [32]byte, +func (b *Bridge) ActiveWalletPubKeyHashAtBlock( blockNumber *big.Int, ) ([20]byte, error) { var result [20]byte @@ -6920,20 +6839,23 @@ func (b *Bridge) WalletPubKeyHashForWalletIDAtBlock( b.caller, b.errorResolver, b.contractAddress, - "walletPubKeyHashForWalletID", + "activeWalletPubKeyHash", &result, - arg_walletId, ) return result, err } -func (b *Bridge) Wallets( - arg_walletPubKeyHash [20]byte, -) (abi.WalletsWallet, error) { - result, err := b.contract.Wallets( +type contractReferences struct { + Bank common.Address + Relay common.Address + EcdsaWalletRegistry common.Address + ReimbursementPool common.Address +} + +func (b *Bridge) ContractReferences() (contractReferences, error) { + result, err := b.contract.ContractReferences( b.callerOptions, - arg_walletPubKeyHash, ) if err != nil { @@ -6941,19 +6863,17 @@ func (b *Bridge) Wallets( err, b.callerOptions.From, nil, - "wallets", - arg_walletPubKeyHash, + "contractReferences", ) } return result, err } -func (b *Bridge) WalletsAtBlock( - arg_walletPubKeyHash [20]byte, +func (b *Bridge) ContractReferencesAtBlock( blockNumber *big.Int, -) (abi.WalletsWallet, error) { - var result abi.WalletsWallet +) (contractReferences, error) { + var result contractReferences err := chainutil.CallAtBlock( b.callerOptions.From, @@ -6963,62 +6883,2010 @@ func (b *Bridge) WalletsAtBlock( b.caller, b.errorResolver, b.contractAddress, - "wallets", + "contractReferences", &result, - arg_walletPubKeyHash, ) - return result, err + return result, err +} + +type depositParameters struct { + DepositDustThreshold uint64 + DepositTreasuryFeeDivisor uint64 + DepositTxMaxFee uint64 + DepositRevealAheadPeriod uint32 +} + +func (b *Bridge) DepositParameters() (depositParameters, error) { + result, err := b.contract.DepositParameters( + b.callerOptions, + ) + + if err != nil { + return result, b.errorResolver.ResolveError( + err, + b.callerOptions.From, + nil, + "depositParameters", + ) + } + + return result, err +} + +func (b *Bridge) DepositParametersAtBlock( + blockNumber *big.Int, +) (depositParameters, error) { + var result depositParameters + + err := chainutil.CallAtBlock( + b.callerOptions.From, + blockNumber, + nil, + b.contractABI, + b.caller, + b.errorResolver, + b.contractAddress, + "depositParameters", + &result, + ) + + return result, err +} + +func (b *Bridge) Deposits( + arg_depositKey *big.Int, +) (abi.DepositDepositRequest, error) { + result, err := b.contract.Deposits( + b.callerOptions, + arg_depositKey, + ) + + if err != nil { + return result, b.errorResolver.ResolveError( + err, + b.callerOptions.From, + nil, + "deposits", + arg_depositKey, + ) + } + + return result, err +} + +func (b *Bridge) DepositsAtBlock( + arg_depositKey *big.Int, + blockNumber *big.Int, +) (abi.DepositDepositRequest, error) { + var result abi.DepositDepositRequest + + err := chainutil.CallAtBlock( + b.callerOptions.From, + blockNumber, + nil, + b.contractABI, + b.caller, + b.errorResolver, + b.contractAddress, + "deposits", + &result, + arg_depositKey, + ) + + return result, err +} + +func (b *Bridge) EcdsaFraudRouter() (common.Address, error) { + result, err := b.contract.EcdsaFraudRouter( + b.callerOptions, + ) + + if err != nil { + return result, b.errorResolver.ResolveError( + err, + b.callerOptions.From, + nil, + "ecdsaFraudRouter", + ) + } + + return result, err +} + +func (b *Bridge) EcdsaFraudRouterAtBlock( + blockNumber *big.Int, +) (common.Address, error) { + var result common.Address + + err := chainutil.CallAtBlock( + b.callerOptions.From, + blockNumber, + nil, + b.contractABI, + b.caller, + b.errorResolver, + b.contractAddress, + "ecdsaFraudRouter", + &result, + ) + + return result, err +} + +func (b *Bridge) EcdsaRetired() (bool, error) { + result, err := b.contract.EcdsaRetired( + b.callerOptions, + ) + + if err != nil { + return result, b.errorResolver.ResolveError( + err, + b.callerOptions.From, + nil, + "ecdsaRetired", + ) + } + + return result, err +} + +func (b *Bridge) EcdsaRetiredAtBlock( + blockNumber *big.Int, +) (bool, error) { + var result bool + + err := chainutil.CallAtBlock( + b.callerOptions.From, + blockNumber, + nil, + b.contractABI, + b.caller, + b.errorResolver, + b.contractAddress, + "ecdsaRetired", + &result, + ) + + return result, err +} + +type fraudParameters struct { + FraudChallengeDepositAmount *big.Int + FraudChallengeDefeatTimeout uint32 + FraudSlashingAmount *big.Int + FraudNotifierRewardMultiplier uint32 +} + +func (b *Bridge) FraudParameters() (fraudParameters, error) { + result, err := b.contract.FraudParameters( + b.callerOptions, + ) + + if err != nil { + return result, b.errorResolver.ResolveError( + err, + b.callerOptions.From, + nil, + "fraudParameters", + ) + } + + return result, err +} + +func (b *Bridge) FraudParametersAtBlock( + blockNumber *big.Int, +) (fraudParameters, error) { + var result fraudParameters + + err := chainutil.CallAtBlock( + b.callerOptions.From, + blockNumber, + nil, + b.contractABI, + b.caller, + b.errorResolver, + b.contractAddress, + "fraudParameters", + &result, + ) + + return result, err +} + +type frostLifecycleContext struct { + FrostRegistry common.Address + WalletID [32]byte +} + +func (b *Bridge) FrostLifecycleContext( + arg_walletPubKeyHash [20]byte, +) (frostLifecycleContext, error) { + result, err := b.contract.FrostLifecycleContext( + b.callerOptions, + arg_walletPubKeyHash, + ) + + if err != nil { + return result, b.errorResolver.ResolveError( + err, + b.callerOptions.From, + nil, + "frostLifecycleContext", + arg_walletPubKeyHash, + ) + } + + return result, err +} + +func (b *Bridge) FrostLifecycleContextAtBlock( + arg_walletPubKeyHash [20]byte, + blockNumber *big.Int, +) (frostLifecycleContext, error) { + var result frostLifecycleContext + + err := chainutil.CallAtBlock( + b.callerOptions.From, + blockNumber, + nil, + b.contractABI, + b.caller, + b.errorResolver, + b.contractAddress, + "frostLifecycleContext", + &result, + arg_walletPubKeyHash, + ) + + return result, err +} + +func (b *Bridge) GetRebateStaking() (common.Address, error) { + result, err := b.contract.GetRebateStaking( + b.callerOptions, + ) + + if err != nil { + return result, b.errorResolver.ResolveError( + err, + b.callerOptions.From, + nil, + "getRebateStaking", + ) + } + + return result, err +} + +func (b *Bridge) GetRebateStakingAtBlock( + blockNumber *big.Int, +) (common.Address, error) { + var result common.Address + + err := chainutil.CallAtBlock( + b.callerOptions.From, + blockNumber, + nil, + b.contractABI, + b.caller, + b.errorResolver, + b.contractAddress, + "getRebateStaking", + &result, + ) + + return result, err +} + +func (b *Bridge) GetRedemptionWatchtower() (common.Address, error) { + result, err := b.contract.GetRedemptionWatchtower( + b.callerOptions, + ) + + if err != nil { + return result, b.errorResolver.ResolveError( + err, + b.callerOptions.From, + nil, + "getRedemptionWatchtower", + ) + } + + return result, err +} + +func (b *Bridge) GetRedemptionWatchtowerAtBlock( + blockNumber *big.Int, +) (common.Address, error) { + var result common.Address + + err := chainutil.CallAtBlock( + b.callerOptions.From, + blockNumber, + nil, + b.contractABI, + b.caller, + b.errorResolver, + b.contractAddress, + "getRedemptionWatchtower", + &result, + ) + + return result, err +} + +func (b *Bridge) Governance() (common.Address, error) { + result, err := b.contract.Governance( + b.callerOptions, + ) + + if err != nil { + return result, b.errorResolver.ResolveError( + err, + b.callerOptions.From, + nil, + "governance", + ) + } + + return result, err +} + +func (b *Bridge) GovernanceAtBlock( + blockNumber *big.Int, +) (common.Address, error) { + var result common.Address + + err := chainutil.CallAtBlock( + b.callerOptions.From, + blockNumber, + nil, + b.contractABI, + b.caller, + b.errorResolver, + b.contractAddress, + "governance", + &result, + ) + + return result, err +} + +func (b *Bridge) IsVaultTrusted( + arg_vault common.Address, +) (bool, error) { + result, err := b.contract.IsVaultTrusted( + b.callerOptions, + arg_vault, + ) + + if err != nil { + return result, b.errorResolver.ResolveError( + err, + b.callerOptions.From, + nil, + "isVaultTrusted", + arg_vault, + ) + } + + return result, err +} + +func (b *Bridge) IsVaultTrustedAtBlock( + arg_vault common.Address, + blockNumber *big.Int, +) (bool, error) { + var result bool + + err := chainutil.CallAtBlock( + b.callerOptions.From, + blockNumber, + nil, + b.contractABI, + b.caller, + b.errorResolver, + b.contractAddress, + "isVaultTrusted", + &result, + arg_vault, + ) + + return result, err +} + +func (b *Bridge) LiveWalletsCount() (uint32, error) { + result, err := b.contract.LiveWalletsCount( + b.callerOptions, + ) + + if err != nil { + return result, b.errorResolver.ResolveError( + err, + b.callerOptions.From, + nil, + "liveWalletsCount", + ) + } + + return result, err +} + +func (b *Bridge) LiveWalletsCountAtBlock( + blockNumber *big.Int, +) (uint32, error) { + var result uint32 + + err := chainutil.CallAtBlock( + b.callerOptions.From, + blockNumber, + nil, + b.contractABI, + b.caller, + b.errorResolver, + b.contractAddress, + "liveWalletsCount", + &result, + ) + + return result, err +} + +func (b *Bridge) MovedFundsSweepRequests( + arg_requestKey *big.Int, +) (abi.MovingFundsMovedFundsSweepRequest, error) { + result, err := b.contract.MovedFundsSweepRequests( + b.callerOptions, + arg_requestKey, + ) + + if err != nil { + return result, b.errorResolver.ResolveError( + err, + b.callerOptions.From, + nil, + "movedFundsSweepRequests", + arg_requestKey, + ) + } + + return result, err +} + +func (b *Bridge) MovedFundsSweepRequestsAtBlock( + arg_requestKey *big.Int, + blockNumber *big.Int, +) (abi.MovingFundsMovedFundsSweepRequest, error) { + var result abi.MovingFundsMovedFundsSweepRequest + + err := chainutil.CallAtBlock( + b.callerOptions.From, + blockNumber, + nil, + b.contractABI, + b.caller, + b.errorResolver, + b.contractAddress, + "movedFundsSweepRequests", + &result, + arg_requestKey, + ) + + return result, err +} + +type movingFundsParameters struct { + MovingFundsTxMaxTotalFee uint64 + MovingFundsDustThreshold uint64 + MovingFundsTimeoutResetDelay uint32 + MovingFundsTimeout uint32 + MovingFundsTimeoutSlashingAmount *big.Int + MovingFundsTimeoutNotifierRewardMultiplier uint32 + MovingFundsCommitmentGasOffset uint16 + MovedFundsSweepTxMaxTotalFee uint64 + MovedFundsSweepTimeout uint32 + MovedFundsSweepTimeoutSlashingAmount *big.Int + MovedFundsSweepTimeoutNotifierRewardMultiplier uint32 +} + +func (b *Bridge) MovingFundsParameters() (movingFundsParameters, error) { + result, err := b.contract.MovingFundsParameters( + b.callerOptions, + ) + + if err != nil { + return result, b.errorResolver.ResolveError( + err, + b.callerOptions.From, + nil, + "movingFundsParameters", + ) + } + + return result, err +} + +func (b *Bridge) MovingFundsParametersAtBlock( + blockNumber *big.Int, +) (movingFundsParameters, error) { + var result movingFundsParameters + + err := chainutil.CallAtBlock( + b.callerOptions.From, + blockNumber, + nil, + b.contractABI, + b.caller, + b.errorResolver, + b.contractAddress, + "movingFundsParameters", + &result, + ) + + return result, err +} + +func (b *Bridge) P2trFraudRouter() (common.Address, error) { + result, err := b.contract.P2trFraudRouter( + b.callerOptions, + ) + + if err != nil { + return result, b.errorResolver.ResolveError( + err, + b.callerOptions.From, + nil, + "p2trFraudRouter", + ) + } + + return result, err +} + +func (b *Bridge) P2trFraudRouterAtBlock( + blockNumber *big.Int, +) (common.Address, error) { + var result common.Address + + err := chainutil.CallAtBlock( + b.callerOptions.From, + blockNumber, + nil, + b.contractABI, + b.caller, + b.errorResolver, + b.contractAddress, + "p2trFraudRouter", + &result, + ) + + return result, err +} + +func (b *Bridge) PendingRedemptions( + arg_redemptionKey *big.Int, +) (abi.RedemptionRedemptionRequest, error) { + result, err := b.contract.PendingRedemptions( + b.callerOptions, + arg_redemptionKey, + ) + + if err != nil { + return result, b.errorResolver.ResolveError( + err, + b.callerOptions.From, + nil, + "pendingRedemptions", + arg_redemptionKey, + ) + } + + return result, err +} + +func (b *Bridge) PendingRedemptionsAtBlock( + arg_redemptionKey *big.Int, + blockNumber *big.Int, +) (abi.RedemptionRedemptionRequest, error) { + var result abi.RedemptionRedemptionRequest + + err := chainutil.CallAtBlock( + b.callerOptions.From, + blockNumber, + nil, + b.contractABI, + b.caller, + b.errorResolver, + b.contractAddress, + "pendingRedemptions", + &result, + arg_redemptionKey, + ) + + return result, err +} + +type redemptionParameters struct { + RedemptionDustThreshold uint64 + RedemptionTreasuryFeeDivisor uint64 + RedemptionTxMaxFee uint64 + RedemptionTxMaxTotalFee uint64 + RedemptionTimeout uint32 + RedemptionTimeoutSlashingAmount *big.Int + RedemptionTimeoutNotifierRewardMultiplier uint32 +} + +func (b *Bridge) RedemptionParameters() (redemptionParameters, error) { + result, err := b.contract.RedemptionParameters( + b.callerOptions, + ) + + if err != nil { + return result, b.errorResolver.ResolveError( + err, + b.callerOptions.From, + nil, + "redemptionParameters", + ) + } + + return result, err +} + +func (b *Bridge) RedemptionParametersAtBlock( + blockNumber *big.Int, +) (redemptionParameters, error) { + var result redemptionParameters + + err := chainutil.CallAtBlock( + b.callerOptions.From, + blockNumber, + nil, + b.contractABI, + b.caller, + b.errorResolver, + b.contractAddress, + "redemptionParameters", + &result, + ) + + return result, err +} + +func (b *Bridge) SpentMainUTXOs( + arg_utxoKey *big.Int, +) (bool, error) { + result, err := b.contract.SpentMainUTXOs( + b.callerOptions, + arg_utxoKey, + ) + + if err != nil { + return result, b.errorResolver.ResolveError( + err, + b.callerOptions.From, + nil, + "spentMainUTXOs", + arg_utxoKey, + ) + } + + return result, err +} + +func (b *Bridge) SpentMainUTXOsAtBlock( + arg_utxoKey *big.Int, + blockNumber *big.Int, +) (bool, error) { + var result bool + + err := chainutil.CallAtBlock( + b.callerOptions.From, + blockNumber, + nil, + b.contractABI, + b.caller, + b.errorResolver, + b.contractAddress, + "spentMainUTXOs", + &result, + arg_utxoKey, + ) + + return result, err +} + +func (b *Bridge) TimedOutRedemptions( + arg_redemptionKey *big.Int, +) (abi.RedemptionRedemptionRequest, error) { + result, err := b.contract.TimedOutRedemptions( + b.callerOptions, + arg_redemptionKey, + ) + + if err != nil { + return result, b.errorResolver.ResolveError( + err, + b.callerOptions.From, + nil, + "timedOutRedemptions", + arg_redemptionKey, + ) + } + + return result, err +} + +func (b *Bridge) TimedOutRedemptionsAtBlock( + arg_redemptionKey *big.Int, + blockNumber *big.Int, +) (abi.RedemptionRedemptionRequest, error) { + var result abi.RedemptionRedemptionRequest + + err := chainutil.CallAtBlock( + b.callerOptions.From, + blockNumber, + nil, + b.contractABI, + b.caller, + b.errorResolver, + b.contractAddress, + "timedOutRedemptions", + &result, + arg_redemptionKey, + ) + + return result, err +} + +func (b *Bridge) Treasury() (common.Address, error) { + result, err := b.contract.Treasury( + b.callerOptions, + ) + + if err != nil { + return result, b.errorResolver.ResolveError( + err, + b.callerOptions.From, + nil, + "treasury", + ) + } + + return result, err +} + +func (b *Bridge) TreasuryAtBlock( + blockNumber *big.Int, +) (common.Address, error) { + var result common.Address + + err := chainutil.CallAtBlock( + b.callerOptions.From, + blockNumber, + nil, + b.contractABI, + b.caller, + b.errorResolver, + b.contractAddress, + "treasury", + &result, + ) + + return result, err +} + +func (b *Bridge) TxProofDifficultyFactor() (*big.Int, error) { + result, err := b.contract.TxProofDifficultyFactor( + b.callerOptions, + ) + + if err != nil { + return result, b.errorResolver.ResolveError( + err, + b.callerOptions.From, + nil, + "txProofDifficultyFactor", + ) + } + + return result, err +} + +func (b *Bridge) TxProofDifficultyFactorAtBlock( + blockNumber *big.Int, +) (*big.Int, error) { + var result *big.Int + + err := chainutil.CallAtBlock( + b.callerOptions.From, + blockNumber, + nil, + b.contractABI, + b.caller, + b.errorResolver, + b.contractAddress, + "txProofDifficultyFactor", + &result, + ) + + return result, err +} + +func (b *Bridge) WalletID( + arg_walletPubKeyHash [20]byte, +) ([32]byte, error) { + result, err := b.contract.WalletID( + b.callerOptions, + arg_walletPubKeyHash, + ) + + if err != nil { + return result, b.errorResolver.ResolveError( + err, + b.callerOptions.From, + nil, + "walletID", + arg_walletPubKeyHash, + ) + } + + return result, err +} + +func (b *Bridge) WalletIDAtBlock( + arg_walletPubKeyHash [20]byte, + blockNumber *big.Int, +) ([32]byte, error) { + var result [32]byte + + err := chainutil.CallAtBlock( + b.callerOptions.From, + blockNumber, + nil, + b.contractABI, + b.caller, + b.errorResolver, + b.contractAddress, + "walletID", + &result, + arg_walletPubKeyHash, + ) + + return result, err +} + +type walletParameters struct { + WalletCreationPeriod uint32 + WalletCreationMinBtcBalance uint64 + WalletCreationMaxBtcBalance uint64 + WalletClosureMinBtcBalance uint64 + WalletMaxAge uint32 + WalletMaxBtcTransfer uint64 + WalletClosingPeriod uint32 +} + +func (b *Bridge) WalletParameters() (walletParameters, error) { + result, err := b.contract.WalletParameters( + b.callerOptions, + ) + + if err != nil { + return result, b.errorResolver.ResolveError( + err, + b.callerOptions.From, + nil, + "walletParameters", + ) + } + + return result, err +} + +func (b *Bridge) WalletParametersAtBlock( + blockNumber *big.Int, +) (walletParameters, error) { + var result walletParameters + + err := chainutil.CallAtBlock( + b.callerOptions.From, + blockNumber, + nil, + b.contractABI, + b.caller, + b.errorResolver, + b.contractAddress, + "walletParameters", + &result, + ) + + return result, err +} + +func (b *Bridge) WalletPubKeyHashForWalletID( + arg_walletId [32]byte, +) ([20]byte, error) { + result, err := b.contract.WalletPubKeyHashForWalletID( + b.callerOptions, + arg_walletId, + ) + + if err != nil { + return result, b.errorResolver.ResolveError( + err, + b.callerOptions.From, + nil, + "walletPubKeyHashForWalletID", + arg_walletId, + ) + } + + return result, err +} + +func (b *Bridge) WalletPubKeyHashForWalletIDAtBlock( + arg_walletId [32]byte, + blockNumber *big.Int, +) ([20]byte, error) { + var result [20]byte + + err := chainutil.CallAtBlock( + b.callerOptions.From, + blockNumber, + nil, + b.contractABI, + b.caller, + b.errorResolver, + b.contractAddress, + "walletPubKeyHashForWalletID", + &result, + arg_walletId, + ) + + return result, err +} + +func (b *Bridge) Wallets( + arg_walletPubKeyHash [20]byte, +) (abi.WalletsWallet, error) { + result, err := b.contract.Wallets( + b.callerOptions, + arg_walletPubKeyHash, + ) + + if err != nil { + return result, b.errorResolver.ResolveError( + err, + b.callerOptions.From, + nil, + "wallets", + arg_walletPubKeyHash, + ) + } + + return result, err +} + +func (b *Bridge) WalletsAtBlock( + arg_walletPubKeyHash [20]byte, + blockNumber *big.Int, +) (abi.WalletsWallet, error) { + var result abi.WalletsWallet + + err := chainutil.CallAtBlock( + b.callerOptions.From, + blockNumber, + nil, + b.contractABI, + b.caller, + b.errorResolver, + b.contractAddress, + "wallets", + &result, + arg_walletPubKeyHash, + ) + + return result, err +} + +func (b *Bridge) WalletsByWalletID( + arg_walletId [32]byte, +) (abi.WalletsWallet, error) { + result, err := b.contract.WalletsByWalletID( + b.callerOptions, + arg_walletId, + ) + + if err != nil { + return result, b.errorResolver.ResolveError( + err, + b.callerOptions.From, + nil, + "walletsByWalletID", + arg_walletId, + ) + } + + return result, err +} + +func (b *Bridge) WalletsByWalletIDAtBlock( + arg_walletId [32]byte, + blockNumber *big.Int, +) (abi.WalletsWallet, error) { + var result abi.WalletsWallet + + err := chainutil.CallAtBlock( + b.callerOptions.From, + blockNumber, + nil, + b.contractABI, + b.caller, + b.errorResolver, + b.contractAddress, + "walletsByWalletID", + &result, + arg_walletId, + ) + + return result, err +} + +// ------ Events ------- + +func (b *Bridge) DepositParametersUpdatedEvent( + opts *ethereum.SubscribeOpts, +) *BDepositParametersUpdatedSubscription { + if opts == nil { + opts = new(ethereum.SubscribeOpts) + } + if opts.Tick == 0 { + opts.Tick = chainutil.DefaultSubscribeOptsTick + } + if opts.PastBlocks == 0 { + opts.PastBlocks = chainutil.DefaultSubscribeOptsPastBlocks + } + + return &BDepositParametersUpdatedSubscription{ + b, + opts, + } +} + +type BDepositParametersUpdatedSubscription struct { + contract *Bridge + opts *ethereum.SubscribeOpts +} + +type bridgeDepositParametersUpdatedFunc func( + DepositDustThreshold uint64, + DepositTreasuryFeeDivisor uint64, + DepositTxMaxFee uint64, + DepositRevealAheadPeriod uint32, + blockNumber uint64, +) + +func (dpus *BDepositParametersUpdatedSubscription) OnEvent( + handler bridgeDepositParametersUpdatedFunc, +) subscription.EventSubscription { + eventChan := make(chan *abi.BridgeDepositParametersUpdated) + ctx, cancelCtx := context.WithCancel(context.Background()) + + go func() { + for { + select { + case <-ctx.Done(): + return + case event := <-eventChan: + handler( + event.DepositDustThreshold, + event.DepositTreasuryFeeDivisor, + event.DepositTxMaxFee, + event.DepositRevealAheadPeriod, + event.Raw.BlockNumber, + ) + } + } + }() + + sub := dpus.Pipe(eventChan) + return subscription.NewEventSubscription(func() { + sub.Unsubscribe() + cancelCtx() + }) +} + +func (dpus *BDepositParametersUpdatedSubscription) Pipe( + sink chan *abi.BridgeDepositParametersUpdated, +) subscription.EventSubscription { + ctx, cancelCtx := context.WithCancel(context.Background()) + go func() { + ticker := time.NewTicker(dpus.opts.Tick) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + lastBlock, err := dpus.contract.blockCounter.CurrentBlock() + if err != nil { + bLogger.Errorf( + "subscription failed to pull events: [%v]", + err, + ) + } + fromBlock := lastBlock - dpus.opts.PastBlocks + + bLogger.Infof( + "subscription monitoring fetching past DepositParametersUpdated events "+ + "starting from block [%v]", + fromBlock, + ) + events, err := dpus.contract.PastDepositParametersUpdatedEvents( + fromBlock, + nil, + ) + if err != nil { + bLogger.Errorf( + "subscription failed to pull events: [%v]", + err, + ) + continue + } + bLogger.Infof( + "subscription monitoring fetched [%v] past DepositParametersUpdated events", + len(events), + ) + + for _, event := range events { + sink <- event + } + } + } + }() + + sub := dpus.contract.watchDepositParametersUpdated( + sink, + ) + + return subscription.NewEventSubscription(func() { + sub.Unsubscribe() + cancelCtx() + }) +} + +func (b *Bridge) watchDepositParametersUpdated( + sink chan *abi.BridgeDepositParametersUpdated, +) event.Subscription { + subscribeFn := func(ctx context.Context) (event.Subscription, error) { + return b.contract.WatchDepositParametersUpdated( + &bind.WatchOpts{Context: ctx}, + sink, + ) + } + + thresholdViolatedFn := func(elapsed time.Duration) { + bLogger.Warnf( + "subscription to event DepositParametersUpdated had to be "+ + "retried [%s] since the last attempt; please inspect "+ + "host chain connectivity", + elapsed, + ) + } + + subscriptionFailedFn := func(err error) { + bLogger.Errorf( + "subscription to event DepositParametersUpdated failed "+ + "with error: [%v]; resubscription attempt will be "+ + "performed", + err, + ) + } + + return chainutil.WithResubscription( + chainutil.SubscriptionBackoffMax, + subscribeFn, + chainutil.SubscriptionAlertThreshold, + thresholdViolatedFn, + subscriptionFailedFn, + ) +} + +func (b *Bridge) PastDepositParametersUpdatedEvents( + startBlock uint64, + endBlock *uint64, +) ([]*abi.BridgeDepositParametersUpdated, error) { + iterator, err := b.contract.FilterDepositParametersUpdated( + &bind.FilterOpts{ + Start: startBlock, + End: endBlock, + }, + ) + if err != nil { + return nil, fmt.Errorf( + "error retrieving past DepositParametersUpdated events: [%v]", + err, + ) + } + + events := make([]*abi.BridgeDepositParametersUpdated, 0) + + for iterator.Next() { + event := iterator.Event + events = append(events, event) + } + + return events, nil +} + +func (b *Bridge) DepositRevealedEvent( + opts *ethereum.SubscribeOpts, + depositorFilter []common.Address, + walletPubKeyHashFilter [][20]byte, +) *BDepositRevealedSubscription { + if opts == nil { + opts = new(ethereum.SubscribeOpts) + } + if opts.Tick == 0 { + opts.Tick = chainutil.DefaultSubscribeOptsTick + } + if opts.PastBlocks == 0 { + opts.PastBlocks = chainutil.DefaultSubscribeOptsPastBlocks + } + + return &BDepositRevealedSubscription{ + b, + opts, + depositorFilter, + walletPubKeyHashFilter, + } +} + +type BDepositRevealedSubscription struct { + contract *Bridge + opts *ethereum.SubscribeOpts + depositorFilter []common.Address + walletPubKeyHashFilter [][20]byte +} + +type bridgeDepositRevealedFunc func( + FundingTxHash [32]byte, + FundingOutputIndex uint32, + Depositor common.Address, + Amount uint64, + BlindingFactor [8]byte, + WalletPubKeyHash [20]byte, + RefundPubKeyHash [20]byte, + RefundLocktime [4]byte, + Vault common.Address, + blockNumber uint64, +) + +func (drs *BDepositRevealedSubscription) OnEvent( + handler bridgeDepositRevealedFunc, +) subscription.EventSubscription { + eventChan := make(chan *abi.BridgeDepositRevealed) + ctx, cancelCtx := context.WithCancel(context.Background()) + + go func() { + for { + select { + case <-ctx.Done(): + return + case event := <-eventChan: + handler( + event.FundingTxHash, + event.FundingOutputIndex, + event.Depositor, + event.Amount, + event.BlindingFactor, + event.WalletPubKeyHash, + event.RefundPubKeyHash, + event.RefundLocktime, + event.Vault, + event.Raw.BlockNumber, + ) + } + } + }() + + sub := drs.Pipe(eventChan) + return subscription.NewEventSubscription(func() { + sub.Unsubscribe() + cancelCtx() + }) +} + +func (drs *BDepositRevealedSubscription) Pipe( + sink chan *abi.BridgeDepositRevealed, +) subscription.EventSubscription { + ctx, cancelCtx := context.WithCancel(context.Background()) + go func() { + ticker := time.NewTicker(drs.opts.Tick) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + lastBlock, err := drs.contract.blockCounter.CurrentBlock() + if err != nil { + bLogger.Errorf( + "subscription failed to pull events: [%v]", + err, + ) + } + fromBlock := lastBlock - drs.opts.PastBlocks + + bLogger.Infof( + "subscription monitoring fetching past DepositRevealed events "+ + "starting from block [%v]", + fromBlock, + ) + events, err := drs.contract.PastDepositRevealedEvents( + fromBlock, + nil, + drs.depositorFilter, + drs.walletPubKeyHashFilter, + ) + if err != nil { + bLogger.Errorf( + "subscription failed to pull events: [%v]", + err, + ) + continue + } + bLogger.Infof( + "subscription monitoring fetched [%v] past DepositRevealed events", + len(events), + ) + + for _, event := range events { + sink <- event + } + } + } + }() + + sub := drs.contract.watchDepositRevealed( + sink, + drs.depositorFilter, + drs.walletPubKeyHashFilter, + ) + + return subscription.NewEventSubscription(func() { + sub.Unsubscribe() + cancelCtx() + }) +} + +func (b *Bridge) watchDepositRevealed( + sink chan *abi.BridgeDepositRevealed, + depositorFilter []common.Address, + walletPubKeyHashFilter [][20]byte, +) event.Subscription { + subscribeFn := func(ctx context.Context) (event.Subscription, error) { + return b.contract.WatchDepositRevealed( + &bind.WatchOpts{Context: ctx}, + sink, + depositorFilter, + walletPubKeyHashFilter, + ) + } + + thresholdViolatedFn := func(elapsed time.Duration) { + bLogger.Warnf( + "subscription to event DepositRevealed had to be "+ + "retried [%s] since the last attempt; please inspect "+ + "host chain connectivity", + elapsed, + ) + } + + subscriptionFailedFn := func(err error) { + bLogger.Errorf( + "subscription to event DepositRevealed failed "+ + "with error: [%v]; resubscription attempt will be "+ + "performed", + err, + ) + } + + return chainutil.WithResubscription( + chainutil.SubscriptionBackoffMax, + subscribeFn, + chainutil.SubscriptionAlertThreshold, + thresholdViolatedFn, + subscriptionFailedFn, + ) +} + +func (b *Bridge) PastDepositRevealedEvents( + startBlock uint64, + endBlock *uint64, + depositorFilter []common.Address, + walletPubKeyHashFilter [][20]byte, +) ([]*abi.BridgeDepositRevealed, error) { + iterator, err := b.contract.FilterDepositRevealed( + &bind.FilterOpts{ + Start: startBlock, + End: endBlock, + }, + depositorFilter, + walletPubKeyHashFilter, + ) + if err != nil { + return nil, fmt.Errorf( + "error retrieving past DepositRevealed events: [%v]", + err, + ) + } + + events := make([]*abi.BridgeDepositRevealed, 0) + + for iterator.Next() { + event := iterator.Event + events = append(events, event) + } + + return events, nil +} + +func (b *Bridge) DepositVaultFixedEvent( + opts *ethereum.SubscribeOpts, + depositKeyFilter []*big.Int, +) *BDepositVaultFixedSubscription { + if opts == nil { + opts = new(ethereum.SubscribeOpts) + } + if opts.Tick == 0 { + opts.Tick = chainutil.DefaultSubscribeOptsTick + } + if opts.PastBlocks == 0 { + opts.PastBlocks = chainutil.DefaultSubscribeOptsPastBlocks + } + + return &BDepositVaultFixedSubscription{ + b, + opts, + depositKeyFilter, + } +} + +type BDepositVaultFixedSubscription struct { + contract *Bridge + opts *ethereum.SubscribeOpts + depositKeyFilter []*big.Int +} + +type bridgeDepositVaultFixedFunc func( + DepositKey *big.Int, + NewVault common.Address, + blockNumber uint64, +) + +func (dvfs *BDepositVaultFixedSubscription) OnEvent( + handler bridgeDepositVaultFixedFunc, +) subscription.EventSubscription { + eventChan := make(chan *abi.BridgeDepositVaultFixed) + ctx, cancelCtx := context.WithCancel(context.Background()) + + go func() { + for { + select { + case <-ctx.Done(): + return + case event := <-eventChan: + handler( + event.DepositKey, + event.NewVault, + event.Raw.BlockNumber, + ) + } + } + }() + + sub := dvfs.Pipe(eventChan) + return subscription.NewEventSubscription(func() { + sub.Unsubscribe() + cancelCtx() + }) +} + +func (dvfs *BDepositVaultFixedSubscription) Pipe( + sink chan *abi.BridgeDepositVaultFixed, +) subscription.EventSubscription { + ctx, cancelCtx := context.WithCancel(context.Background()) + go func() { + ticker := time.NewTicker(dvfs.opts.Tick) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + lastBlock, err := dvfs.contract.blockCounter.CurrentBlock() + if err != nil { + bLogger.Errorf( + "subscription failed to pull events: [%v]", + err, + ) + } + fromBlock := lastBlock - dvfs.opts.PastBlocks + + bLogger.Infof( + "subscription monitoring fetching past DepositVaultFixed events "+ + "starting from block [%v]", + fromBlock, + ) + events, err := dvfs.contract.PastDepositVaultFixedEvents( + fromBlock, + nil, + dvfs.depositKeyFilter, + ) + if err != nil { + bLogger.Errorf( + "subscription failed to pull events: [%v]", + err, + ) + continue + } + bLogger.Infof( + "subscription monitoring fetched [%v] past DepositVaultFixed events", + len(events), + ) + + for _, event := range events { + sink <- event + } + } + } + }() + + sub := dvfs.contract.watchDepositVaultFixed( + sink, + dvfs.depositKeyFilter, + ) + + return subscription.NewEventSubscription(func() { + sub.Unsubscribe() + cancelCtx() + }) +} + +func (b *Bridge) watchDepositVaultFixed( + sink chan *abi.BridgeDepositVaultFixed, + depositKeyFilter []*big.Int, +) event.Subscription { + subscribeFn := func(ctx context.Context) (event.Subscription, error) { + return b.contract.WatchDepositVaultFixed( + &bind.WatchOpts{Context: ctx}, + sink, + depositKeyFilter, + ) + } + + thresholdViolatedFn := func(elapsed time.Duration) { + bLogger.Warnf( + "subscription to event DepositVaultFixed had to be "+ + "retried [%s] since the last attempt; please inspect "+ + "host chain connectivity", + elapsed, + ) + } + + subscriptionFailedFn := func(err error) { + bLogger.Errorf( + "subscription to event DepositVaultFixed failed "+ + "with error: [%v]; resubscription attempt will be "+ + "performed", + err, + ) + } + + return chainutil.WithResubscription( + chainutil.SubscriptionBackoffMax, + subscribeFn, + chainutil.SubscriptionAlertThreshold, + thresholdViolatedFn, + subscriptionFailedFn, + ) +} + +func (b *Bridge) PastDepositVaultFixedEvents( + startBlock uint64, + endBlock *uint64, + depositKeyFilter []*big.Int, +) ([]*abi.BridgeDepositVaultFixed, error) { + iterator, err := b.contract.FilterDepositVaultFixed( + &bind.FilterOpts{ + Start: startBlock, + End: endBlock, + }, + depositKeyFilter, + ) + if err != nil { + return nil, fmt.Errorf( + "error retrieving past DepositVaultFixed events: [%v]", + err, + ) + } + + events := make([]*abi.BridgeDepositVaultFixed, 0) + + for iterator.Next() { + event := iterator.Event + events = append(events, event) + } + + return events, nil +} + +func (b *Bridge) DepositsSweptEvent( + opts *ethereum.SubscribeOpts, +) *BDepositsSweptSubscription { + if opts == nil { + opts = new(ethereum.SubscribeOpts) + } + if opts.Tick == 0 { + opts.Tick = chainutil.DefaultSubscribeOptsTick + } + if opts.PastBlocks == 0 { + opts.PastBlocks = chainutil.DefaultSubscribeOptsPastBlocks + } + + return &BDepositsSweptSubscription{ + b, + opts, + } +} + +type BDepositsSweptSubscription struct { + contract *Bridge + opts *ethereum.SubscribeOpts +} + +type bridgeDepositsSweptFunc func( + WalletPubKeyHash [20]byte, + SweepTxHash [32]byte, + blockNumber uint64, +) + +func (dss *BDepositsSweptSubscription) OnEvent( + handler bridgeDepositsSweptFunc, +) subscription.EventSubscription { + eventChan := make(chan *abi.BridgeDepositsSwept) + ctx, cancelCtx := context.WithCancel(context.Background()) + + go func() { + for { + select { + case <-ctx.Done(): + return + case event := <-eventChan: + handler( + event.WalletPubKeyHash, + event.SweepTxHash, + event.Raw.BlockNumber, + ) + } + } + }() + + sub := dss.Pipe(eventChan) + return subscription.NewEventSubscription(func() { + sub.Unsubscribe() + cancelCtx() + }) +} + +func (dss *BDepositsSweptSubscription) Pipe( + sink chan *abi.BridgeDepositsSwept, +) subscription.EventSubscription { + ctx, cancelCtx := context.WithCancel(context.Background()) + go func() { + ticker := time.NewTicker(dss.opts.Tick) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + lastBlock, err := dss.contract.blockCounter.CurrentBlock() + if err != nil { + bLogger.Errorf( + "subscription failed to pull events: [%v]", + err, + ) + } + fromBlock := lastBlock - dss.opts.PastBlocks + + bLogger.Infof( + "subscription monitoring fetching past DepositsSwept events "+ + "starting from block [%v]", + fromBlock, + ) + events, err := dss.contract.PastDepositsSweptEvents( + fromBlock, + nil, + ) + if err != nil { + bLogger.Errorf( + "subscription failed to pull events: [%v]", + err, + ) + continue + } + bLogger.Infof( + "subscription monitoring fetched [%v] past DepositsSwept events", + len(events), + ) + + for _, event := range events { + sink <- event + } + } + } + }() + + sub := dss.contract.watchDepositsSwept( + sink, + ) + + return subscription.NewEventSubscription(func() { + sub.Unsubscribe() + cancelCtx() + }) +} + +func (b *Bridge) watchDepositsSwept( + sink chan *abi.BridgeDepositsSwept, +) event.Subscription { + subscribeFn := func(ctx context.Context) (event.Subscription, error) { + return b.contract.WatchDepositsSwept( + &bind.WatchOpts{Context: ctx}, + sink, + ) + } + + thresholdViolatedFn := func(elapsed time.Duration) { + bLogger.Warnf( + "subscription to event DepositsSwept had to be "+ + "retried [%s] since the last attempt; please inspect "+ + "host chain connectivity", + elapsed, + ) + } + + subscriptionFailedFn := func(err error) { + bLogger.Errorf( + "subscription to event DepositsSwept failed "+ + "with error: [%v]; resubscription attempt will be "+ + "performed", + err, + ) + } + + return chainutil.WithResubscription( + chainutil.SubscriptionBackoffMax, + subscribeFn, + chainutil.SubscriptionAlertThreshold, + thresholdViolatedFn, + subscriptionFailedFn, + ) +} + +func (b *Bridge) PastDepositsSweptEvents( + startBlock uint64, + endBlock *uint64, +) ([]*abi.BridgeDepositsSwept, error) { + iterator, err := b.contract.FilterDepositsSwept( + &bind.FilterOpts{ + Start: startBlock, + End: endBlock, + }, + ) + if err != nil { + return nil, fmt.Errorf( + "error retrieving past DepositsSwept events: [%v]", + err, + ) + } + + events := make([]*abi.BridgeDepositsSwept, 0) + + for iterator.Next() { + event := iterator.Event + events = append(events, event) + } + + return events, nil +} + +func (b *Bridge) EcdsaFraudRouterSetEvent( + opts *ethereum.SubscribeOpts, +) *BEcdsaFraudRouterSetSubscription { + if opts == nil { + opts = new(ethereum.SubscribeOpts) + } + if opts.Tick == 0 { + opts.Tick = chainutil.DefaultSubscribeOptsTick + } + if opts.PastBlocks == 0 { + opts.PastBlocks = chainutil.DefaultSubscribeOptsPastBlocks + } + + return &BEcdsaFraudRouterSetSubscription{ + b, + opts, + } +} + +type BEcdsaFraudRouterSetSubscription struct { + contract *Bridge + opts *ethereum.SubscribeOpts +} + +type bridgeEcdsaFraudRouterSetFunc func( + EcdsaFraudRouter common.Address, + blockNumber uint64, +) + +func (efrss *BEcdsaFraudRouterSetSubscription) OnEvent( + handler bridgeEcdsaFraudRouterSetFunc, +) subscription.EventSubscription { + eventChan := make(chan *abi.BridgeEcdsaFraudRouterSet) + ctx, cancelCtx := context.WithCancel(context.Background()) + + go func() { + for { + select { + case <-ctx.Done(): + return + case event := <-eventChan: + handler( + event.EcdsaFraudRouter, + event.Raw.BlockNumber, + ) + } + } + }() + + sub := efrss.Pipe(eventChan) + return subscription.NewEventSubscription(func() { + sub.Unsubscribe() + cancelCtx() + }) +} + +func (efrss *BEcdsaFraudRouterSetSubscription) Pipe( + sink chan *abi.BridgeEcdsaFraudRouterSet, +) subscription.EventSubscription { + ctx, cancelCtx := context.WithCancel(context.Background()) + go func() { + ticker := time.NewTicker(efrss.opts.Tick) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + lastBlock, err := efrss.contract.blockCounter.CurrentBlock() + if err != nil { + bLogger.Errorf( + "subscription failed to pull events: [%v]", + err, + ) + } + fromBlock := lastBlock - efrss.opts.PastBlocks + + bLogger.Infof( + "subscription monitoring fetching past EcdsaFraudRouterSet events "+ + "starting from block [%v]", + fromBlock, + ) + events, err := efrss.contract.PastEcdsaFraudRouterSetEvents( + fromBlock, + nil, + ) + if err != nil { + bLogger.Errorf( + "subscription failed to pull events: [%v]", + err, + ) + continue + } + bLogger.Infof( + "subscription monitoring fetched [%v] past EcdsaFraudRouterSet events", + len(events), + ) + + for _, event := range events { + sink <- event + } + } + } + }() + + sub := efrss.contract.watchEcdsaFraudRouterSet( + sink, + ) + + return subscription.NewEventSubscription(func() { + sub.Unsubscribe() + cancelCtx() + }) +} + +func (b *Bridge) watchEcdsaFraudRouterSet( + sink chan *abi.BridgeEcdsaFraudRouterSet, +) event.Subscription { + subscribeFn := func(ctx context.Context) (event.Subscription, error) { + return b.contract.WatchEcdsaFraudRouterSet( + &bind.WatchOpts{Context: ctx}, + sink, + ) + } + + thresholdViolatedFn := func(elapsed time.Duration) { + bLogger.Warnf( + "subscription to event EcdsaFraudRouterSet had to be "+ + "retried [%s] since the last attempt; please inspect "+ + "host chain connectivity", + elapsed, + ) + } + + subscriptionFailedFn := func(err error) { + bLogger.Errorf( + "subscription to event EcdsaFraudRouterSet failed "+ + "with error: [%v]; resubscription attempt will be "+ + "performed", + err, + ) + } + + return chainutil.WithResubscription( + chainutil.SubscriptionBackoffMax, + subscribeFn, + chainutil.SubscriptionAlertThreshold, + thresholdViolatedFn, + subscriptionFailedFn, + ) } -func (b *Bridge) WalletsByWalletID( - arg_walletId [32]byte, -) (abi.WalletsWallet, error) { - result, err := b.contract.WalletsByWalletID( - b.callerOptions, - arg_walletId, +func (b *Bridge) PastEcdsaFraudRouterSetEvents( + startBlock uint64, + endBlock *uint64, +) ([]*abi.BridgeEcdsaFraudRouterSet, error) { + iterator, err := b.contract.FilterEcdsaFraudRouterSet( + &bind.FilterOpts{ + Start: startBlock, + End: endBlock, + }, ) - if err != nil { - return result, b.errorResolver.ResolveError( + return nil, fmt.Errorf( + "error retrieving past EcdsaFraudRouterSet events: [%v]", err, - b.callerOptions.From, - nil, - "walletsByWalletID", - arg_walletId, ) } - return result, err -} - -func (b *Bridge) WalletsByWalletIDAtBlock( - arg_walletId [32]byte, - blockNumber *big.Int, -) (abi.WalletsWallet, error) { - var result abi.WalletsWallet + events := make([]*abi.BridgeEcdsaFraudRouterSet, 0) - err := chainutil.CallAtBlock( - b.callerOptions.From, - blockNumber, - nil, - b.contractABI, - b.caller, - b.errorResolver, - b.contractAddress, - "walletsByWalletID", - &result, - arg_walletId, - ) + for iterator.Next() { + event := iterator.Event + events = append(events, event) + } - return result, err + return events, nil } -// ------ Events ------- - -func (b *Bridge) DepositParametersUpdatedEvent( +func (b *Bridge) EcdsaRetiredEvent( opts *ethereum.SubscribeOpts, -) *BDepositParametersUpdatedSubscription { +) *BEcdsaRetiredSubscription { if opts == nil { opts = new(ethereum.SubscribeOpts) } @@ -7029,29 +8897,25 @@ func (b *Bridge) DepositParametersUpdatedEvent( opts.PastBlocks = chainutil.DefaultSubscribeOptsPastBlocks } - return &BDepositParametersUpdatedSubscription{ + return &BEcdsaRetiredSubscription{ b, opts, } } -type BDepositParametersUpdatedSubscription struct { +type BEcdsaRetiredSubscription struct { contract *Bridge opts *ethereum.SubscribeOpts } -type bridgeDepositParametersUpdatedFunc func( - DepositDustThreshold uint64, - DepositTreasuryFeeDivisor uint64, - DepositTxMaxFee uint64, - DepositRevealAheadPeriod uint32, +type bridgeEcdsaRetiredFunc func( blockNumber uint64, ) -func (dpus *BDepositParametersUpdatedSubscription) OnEvent( - handler bridgeDepositParametersUpdatedFunc, +func (ers *BEcdsaRetiredSubscription) OnEvent( + handler bridgeEcdsaRetiredFunc, ) subscription.EventSubscription { - eventChan := make(chan *abi.BridgeDepositParametersUpdated) + eventChan := make(chan *abi.BridgeEcdsaRetired) ctx, cancelCtx := context.WithCancel(context.Background()) go func() { @@ -7061,50 +8925,46 @@ func (dpus *BDepositParametersUpdatedSubscription) OnEvent( return case event := <-eventChan: handler( - event.DepositDustThreshold, - event.DepositTreasuryFeeDivisor, - event.DepositTxMaxFee, - event.DepositRevealAheadPeriod, event.Raw.BlockNumber, ) } } }() - sub := dpus.Pipe(eventChan) + sub := ers.Pipe(eventChan) return subscription.NewEventSubscription(func() { sub.Unsubscribe() cancelCtx() }) } -func (dpus *BDepositParametersUpdatedSubscription) Pipe( - sink chan *abi.BridgeDepositParametersUpdated, +func (ers *BEcdsaRetiredSubscription) Pipe( + sink chan *abi.BridgeEcdsaRetired, ) subscription.EventSubscription { ctx, cancelCtx := context.WithCancel(context.Background()) go func() { - ticker := time.NewTicker(dpus.opts.Tick) + ticker := time.NewTicker(ers.opts.Tick) defer ticker.Stop() for { select { case <-ctx.Done(): return case <-ticker.C: - lastBlock, err := dpus.contract.blockCounter.CurrentBlock() + lastBlock, err := ers.contract.blockCounter.CurrentBlock() if err != nil { bLogger.Errorf( "subscription failed to pull events: [%v]", err, ) } - fromBlock := lastBlock - dpus.opts.PastBlocks + fromBlock := lastBlock - ers.opts.PastBlocks bLogger.Infof( - "subscription monitoring fetching past DepositParametersUpdated events "+ + "subscription monitoring fetching past EcdsaRetired events "+ "starting from block [%v]", fromBlock, ) - events, err := dpus.contract.PastDepositParametersUpdatedEvents( + events, err := ers.contract.PastEcdsaRetiredEvents( fromBlock, nil, ) @@ -7116,7 +8976,7 @@ func (dpus *BDepositParametersUpdatedSubscription) Pipe( continue } bLogger.Infof( - "subscription monitoring fetched [%v] past DepositParametersUpdated events", + "subscription monitoring fetched [%v] past EcdsaRetired events", len(events), ) @@ -7127,7 +8987,7 @@ func (dpus *BDepositParametersUpdatedSubscription) Pipe( } }() - sub := dpus.contract.watchDepositParametersUpdated( + sub := ers.contract.watchEcdsaRetired( sink, ) @@ -7137,11 +8997,11 @@ func (dpus *BDepositParametersUpdatedSubscription) Pipe( }) } -func (b *Bridge) watchDepositParametersUpdated( - sink chan *abi.BridgeDepositParametersUpdated, +func (b *Bridge) watchEcdsaRetired( + sink chan *abi.BridgeEcdsaRetired, ) event.Subscription { subscribeFn := func(ctx context.Context) (event.Subscription, error) { - return b.contract.WatchDepositParametersUpdated( + return b.contract.WatchEcdsaRetired( &bind.WatchOpts{Context: ctx}, sink, ) @@ -7149,7 +9009,7 @@ func (b *Bridge) watchDepositParametersUpdated( thresholdViolatedFn := func(elapsed time.Duration) { bLogger.Warnf( - "subscription to event DepositParametersUpdated had to be "+ + "subscription to event EcdsaRetired had to be "+ "retried [%s] since the last attempt; please inspect "+ "host chain connectivity", elapsed, @@ -7158,7 +9018,7 @@ func (b *Bridge) watchDepositParametersUpdated( subscriptionFailedFn := func(err error) { bLogger.Errorf( - "subscription to event DepositParametersUpdated failed "+ + "subscription to event EcdsaRetired failed "+ "with error: [%v]; resubscription attempt will be "+ "performed", err, @@ -7174,11 +9034,11 @@ func (b *Bridge) watchDepositParametersUpdated( ) } -func (b *Bridge) PastDepositParametersUpdatedEvents( +func (b *Bridge) PastEcdsaRetiredEvents( startBlock uint64, endBlock *uint64, -) ([]*abi.BridgeDepositParametersUpdated, error) { - iterator, err := b.contract.FilterDepositParametersUpdated( +) ([]*abi.BridgeEcdsaRetired, error) { + iterator, err := b.contract.FilterEcdsaRetired( &bind.FilterOpts{ Start: startBlock, End: endBlock, @@ -7186,12 +9046,12 @@ func (b *Bridge) PastDepositParametersUpdatedEvents( ) if err != nil { return nil, fmt.Errorf( - "error retrieving past DepositParametersUpdated events: [%v]", + "error retrieving past EcdsaRetired events: [%v]", err, ) } - events := make([]*abi.BridgeDepositParametersUpdated, 0) + events := make([]*abi.BridgeEcdsaRetired, 0) for iterator.Next() { event := iterator.Event @@ -7201,11 +9061,9 @@ func (b *Bridge) PastDepositParametersUpdatedEvents( return events, nil } -func (b *Bridge) DepositRevealedEvent( +func (b *Bridge) FraudParametersUpdatedEvent( opts *ethereum.SubscribeOpts, - depositorFilter []common.Address, - walletPubKeyHashFilter [][20]byte, -) *BDepositRevealedSubscription { +) *BFraudParametersUpdatedSubscription { if opts == nil { opts = new(ethereum.SubscribeOpts) } @@ -7216,38 +9074,29 @@ func (b *Bridge) DepositRevealedEvent( opts.PastBlocks = chainutil.DefaultSubscribeOptsPastBlocks } - return &BDepositRevealedSubscription{ + return &BFraudParametersUpdatedSubscription{ b, opts, - depositorFilter, - walletPubKeyHashFilter, } } -type BDepositRevealedSubscription struct { - contract *Bridge - opts *ethereum.SubscribeOpts - depositorFilter []common.Address - walletPubKeyHashFilter [][20]byte +type BFraudParametersUpdatedSubscription struct { + contract *Bridge + opts *ethereum.SubscribeOpts } -type bridgeDepositRevealedFunc func( - FundingTxHash [32]byte, - FundingOutputIndex uint32, - Depositor common.Address, - Amount uint64, - BlindingFactor [8]byte, - WalletPubKeyHash [20]byte, - RefundPubKeyHash [20]byte, - RefundLocktime [4]byte, - Vault common.Address, +type bridgeFraudParametersUpdatedFunc func( + FraudChallengeDepositAmount *big.Int, + FraudChallengeDefeatTimeout uint32, + FraudSlashingAmount *big.Int, + FraudNotifierRewardMultiplier uint32, blockNumber uint64, ) -func (drs *BDepositRevealedSubscription) OnEvent( - handler bridgeDepositRevealedFunc, +func (fpus *BFraudParametersUpdatedSubscription) OnEvent( + handler bridgeFraudParametersUpdatedFunc, ) subscription.EventSubscription { - eventChan := make(chan *abi.BridgeDepositRevealed) + eventChan := make(chan *abi.BridgeFraudParametersUpdated) ctx, cancelCtx := context.WithCancel(context.Background()) go func() { @@ -7257,59 +9106,52 @@ func (drs *BDepositRevealedSubscription) OnEvent( return case event := <-eventChan: handler( - event.FundingTxHash, - event.FundingOutputIndex, - event.Depositor, - event.Amount, - event.BlindingFactor, - event.WalletPubKeyHash, - event.RefundPubKeyHash, - event.RefundLocktime, - event.Vault, + event.FraudChallengeDepositAmount, + event.FraudChallengeDefeatTimeout, + event.FraudSlashingAmount, + event.FraudNotifierRewardMultiplier, event.Raw.BlockNumber, ) } } }() - sub := drs.Pipe(eventChan) + sub := fpus.Pipe(eventChan) return subscription.NewEventSubscription(func() { sub.Unsubscribe() cancelCtx() }) } -func (drs *BDepositRevealedSubscription) Pipe( - sink chan *abi.BridgeDepositRevealed, +func (fpus *BFraudParametersUpdatedSubscription) Pipe( + sink chan *abi.BridgeFraudParametersUpdated, ) subscription.EventSubscription { ctx, cancelCtx := context.WithCancel(context.Background()) go func() { - ticker := time.NewTicker(drs.opts.Tick) + ticker := time.NewTicker(fpus.opts.Tick) defer ticker.Stop() for { select { case <-ctx.Done(): return case <-ticker.C: - lastBlock, err := drs.contract.blockCounter.CurrentBlock() + lastBlock, err := fpus.contract.blockCounter.CurrentBlock() if err != nil { bLogger.Errorf( "subscription failed to pull events: [%v]", err, ) } - fromBlock := lastBlock - drs.opts.PastBlocks + fromBlock := lastBlock - fpus.opts.PastBlocks bLogger.Infof( - "subscription monitoring fetching past DepositRevealed events "+ + "subscription monitoring fetching past FraudParametersUpdated events "+ "starting from block [%v]", fromBlock, ) - events, err := drs.contract.PastDepositRevealedEvents( + events, err := fpus.contract.PastFraudParametersUpdatedEvents( fromBlock, nil, - drs.depositorFilter, - drs.walletPubKeyHashFilter, ) if err != nil { bLogger.Errorf( @@ -7319,7 +9161,7 @@ func (drs *BDepositRevealedSubscription) Pipe( continue } bLogger.Infof( - "subscription monitoring fetched [%v] past DepositRevealed events", + "subscription monitoring fetched [%v] past FraudParametersUpdated events", len(events), ) @@ -7330,10 +9172,8 @@ func (drs *BDepositRevealedSubscription) Pipe( } }() - sub := drs.contract.watchDepositRevealed( + sub := fpus.contract.watchFraudParametersUpdated( sink, - drs.depositorFilter, - drs.walletPubKeyHashFilter, ) return subscription.NewEventSubscription(func() { @@ -7342,23 +9182,19 @@ func (drs *BDepositRevealedSubscription) Pipe( }) } -func (b *Bridge) watchDepositRevealed( - sink chan *abi.BridgeDepositRevealed, - depositorFilter []common.Address, - walletPubKeyHashFilter [][20]byte, +func (b *Bridge) watchFraudParametersUpdated( + sink chan *abi.BridgeFraudParametersUpdated, ) event.Subscription { subscribeFn := func(ctx context.Context) (event.Subscription, error) { - return b.contract.WatchDepositRevealed( + return b.contract.WatchFraudParametersUpdated( &bind.WatchOpts{Context: ctx}, sink, - depositorFilter, - walletPubKeyHashFilter, ) } thresholdViolatedFn := func(elapsed time.Duration) { bLogger.Warnf( - "subscription to event DepositRevealed had to be "+ + "subscription to event FraudParametersUpdated had to be "+ "retried [%s] since the last attempt; please inspect "+ "host chain connectivity", elapsed, @@ -7367,7 +9203,7 @@ func (b *Bridge) watchDepositRevealed( subscriptionFailedFn := func(err error) { bLogger.Errorf( - "subscription to event DepositRevealed failed "+ + "subscription to event FraudParametersUpdated failed "+ "with error: [%v]; resubscription attempt will be "+ "performed", err, @@ -7383,28 +9219,24 @@ func (b *Bridge) watchDepositRevealed( ) } -func (b *Bridge) PastDepositRevealedEvents( +func (b *Bridge) PastFraudParametersUpdatedEvents( startBlock uint64, endBlock *uint64, - depositorFilter []common.Address, - walletPubKeyHashFilter [][20]byte, -) ([]*abi.BridgeDepositRevealed, error) { - iterator, err := b.contract.FilterDepositRevealed( +) ([]*abi.BridgeFraudParametersUpdated, error) { + iterator, err := b.contract.FilterFraudParametersUpdated( &bind.FilterOpts{ Start: startBlock, End: endBlock, }, - depositorFilter, - walletPubKeyHashFilter, ) if err != nil { return nil, fmt.Errorf( - "error retrieving past DepositRevealed events: [%v]", + "error retrieving past FraudParametersUpdated events: [%v]", err, ) } - events := make([]*abi.BridgeDepositRevealed, 0) + events := make([]*abi.BridgeFraudParametersUpdated, 0) for iterator.Next() { event := iterator.Event @@ -7414,10 +9246,9 @@ func (b *Bridge) PastDepositRevealedEvents( return events, nil } -func (b *Bridge) DepositVaultFixedEvent( +func (b *Bridge) FrostWalletRegistrySetEvent( opts *ethereum.SubscribeOpts, - depositKeyFilter []*big.Int, -) *BDepositVaultFixedSubscription { +) *BFrostWalletRegistrySetSubscription { if opts == nil { opts = new(ethereum.SubscribeOpts) } @@ -7428,29 +9259,26 @@ func (b *Bridge) DepositVaultFixedEvent( opts.PastBlocks = chainutil.DefaultSubscribeOptsPastBlocks } - return &BDepositVaultFixedSubscription{ + return &BFrostWalletRegistrySetSubscription{ b, opts, - depositKeyFilter, } } -type BDepositVaultFixedSubscription struct { - contract *Bridge - opts *ethereum.SubscribeOpts - depositKeyFilter []*big.Int +type BFrostWalletRegistrySetSubscription struct { + contract *Bridge + opts *ethereum.SubscribeOpts } -type bridgeDepositVaultFixedFunc func( - DepositKey *big.Int, - NewVault common.Address, +type bridgeFrostWalletRegistrySetFunc func( + FrostWalletRegistry common.Address, blockNumber uint64, ) -func (dvfs *BDepositVaultFixedSubscription) OnEvent( - handler bridgeDepositVaultFixedFunc, +func (fwrss *BFrostWalletRegistrySetSubscription) OnEvent( + handler bridgeFrostWalletRegistrySetFunc, ) subscription.EventSubscription { - eventChan := make(chan *abi.BridgeDepositVaultFixed) + eventChan := make(chan *abi.BridgeFrostWalletRegistrySet) ctx, cancelCtx := context.WithCancel(context.Background()) go func() { @@ -7460,51 +9288,49 @@ func (dvfs *BDepositVaultFixedSubscription) OnEvent( return case event := <-eventChan: handler( - event.DepositKey, - event.NewVault, + event.FrostWalletRegistry, event.Raw.BlockNumber, ) } } }() - sub := dvfs.Pipe(eventChan) + sub := fwrss.Pipe(eventChan) return subscription.NewEventSubscription(func() { sub.Unsubscribe() cancelCtx() }) } -func (dvfs *BDepositVaultFixedSubscription) Pipe( - sink chan *abi.BridgeDepositVaultFixed, +func (fwrss *BFrostWalletRegistrySetSubscription) Pipe( + sink chan *abi.BridgeFrostWalletRegistrySet, ) subscription.EventSubscription { ctx, cancelCtx := context.WithCancel(context.Background()) go func() { - ticker := time.NewTicker(dvfs.opts.Tick) + ticker := time.NewTicker(fwrss.opts.Tick) defer ticker.Stop() for { select { case <-ctx.Done(): return case <-ticker.C: - lastBlock, err := dvfs.contract.blockCounter.CurrentBlock() + lastBlock, err := fwrss.contract.blockCounter.CurrentBlock() if err != nil { bLogger.Errorf( "subscription failed to pull events: [%v]", err, ) } - fromBlock := lastBlock - dvfs.opts.PastBlocks + fromBlock := lastBlock - fwrss.opts.PastBlocks bLogger.Infof( - "subscription monitoring fetching past DepositVaultFixed events "+ + "subscription monitoring fetching past FrostWalletRegistrySet events "+ "starting from block [%v]", fromBlock, ) - events, err := dvfs.contract.PastDepositVaultFixedEvents( + events, err := fwrss.contract.PastFrostWalletRegistrySetEvents( fromBlock, nil, - dvfs.depositKeyFilter, ) if err != nil { bLogger.Errorf( @@ -7514,7 +9340,7 @@ func (dvfs *BDepositVaultFixedSubscription) Pipe( continue } bLogger.Infof( - "subscription monitoring fetched [%v] past DepositVaultFixed events", + "subscription monitoring fetched [%v] past FrostWalletRegistrySet events", len(events), ) @@ -7525,9 +9351,8 @@ func (dvfs *BDepositVaultFixedSubscription) Pipe( } }() - sub := dvfs.contract.watchDepositVaultFixed( + sub := fwrss.contract.watchFrostWalletRegistrySet( sink, - dvfs.depositKeyFilter, ) return subscription.NewEventSubscription(func() { @@ -7536,21 +9361,19 @@ func (dvfs *BDepositVaultFixedSubscription) Pipe( }) } -func (b *Bridge) watchDepositVaultFixed( - sink chan *abi.BridgeDepositVaultFixed, - depositKeyFilter []*big.Int, +func (b *Bridge) watchFrostWalletRegistrySet( + sink chan *abi.BridgeFrostWalletRegistrySet, ) event.Subscription { subscribeFn := func(ctx context.Context) (event.Subscription, error) { - return b.contract.WatchDepositVaultFixed( + return b.contract.WatchFrostWalletRegistrySet( &bind.WatchOpts{Context: ctx}, sink, - depositKeyFilter, ) } thresholdViolatedFn := func(elapsed time.Duration) { bLogger.Warnf( - "subscription to event DepositVaultFixed had to be "+ + "subscription to event FrostWalletRegistrySet had to be "+ "retried [%s] since the last attempt; please inspect "+ "host chain connectivity", elapsed, @@ -7559,7 +9382,7 @@ func (b *Bridge) watchDepositVaultFixed( subscriptionFailedFn := func(err error) { bLogger.Errorf( - "subscription to event DepositVaultFixed failed "+ + "subscription to event FrostWalletRegistrySet failed "+ "with error: [%v]; resubscription attempt will be "+ "performed", err, @@ -7575,26 +9398,24 @@ func (b *Bridge) watchDepositVaultFixed( ) } -func (b *Bridge) PastDepositVaultFixedEvents( +func (b *Bridge) PastFrostWalletRegistrySetEvents( startBlock uint64, endBlock *uint64, - depositKeyFilter []*big.Int, -) ([]*abi.BridgeDepositVaultFixed, error) { - iterator, err := b.contract.FilterDepositVaultFixed( +) ([]*abi.BridgeFrostWalletRegistrySet, error) { + iterator, err := b.contract.FilterFrostWalletRegistrySet( &bind.FilterOpts{ Start: startBlock, End: endBlock, }, - depositKeyFilter, ) if err != nil { return nil, fmt.Errorf( - "error retrieving past DepositVaultFixed events: [%v]", + "error retrieving past FrostWalletRegistrySet events: [%v]", err, ) } - events := make([]*abi.BridgeDepositVaultFixed, 0) + events := make([]*abi.BridgeFrostWalletRegistrySet, 0) for iterator.Next() { event := iterator.Event @@ -7604,9 +9425,9 @@ func (b *Bridge) PastDepositVaultFixedEvents( return events, nil } -func (b *Bridge) DepositsSweptEvent( +func (b *Bridge) GovernanceTransferredEvent( opts *ethereum.SubscribeOpts, -) *BDepositsSweptSubscription { +) *BGovernanceTransferredSubscription { if opts == nil { opts = new(ethereum.SubscribeOpts) } @@ -7617,27 +9438,27 @@ func (b *Bridge) DepositsSweptEvent( opts.PastBlocks = chainutil.DefaultSubscribeOptsPastBlocks } - return &BDepositsSweptSubscription{ + return &BGovernanceTransferredSubscription{ b, opts, } } -type BDepositsSweptSubscription struct { +type BGovernanceTransferredSubscription struct { contract *Bridge opts *ethereum.SubscribeOpts } -type bridgeDepositsSweptFunc func( - WalletPubKeyHash [20]byte, - SweepTxHash [32]byte, +type bridgeGovernanceTransferredFunc func( + OldGovernance common.Address, + NewGovernance common.Address, blockNumber uint64, ) -func (dss *BDepositsSweptSubscription) OnEvent( - handler bridgeDepositsSweptFunc, +func (gts *BGovernanceTransferredSubscription) OnEvent( + handler bridgeGovernanceTransferredFunc, ) subscription.EventSubscription { - eventChan := make(chan *abi.BridgeDepositsSwept) + eventChan := make(chan *abi.BridgeGovernanceTransferred) ctx, cancelCtx := context.WithCancel(context.Background()) go func() { @@ -7647,48 +9468,48 @@ func (dss *BDepositsSweptSubscription) OnEvent( return case event := <-eventChan: handler( - event.WalletPubKeyHash, - event.SweepTxHash, + event.OldGovernance, + event.NewGovernance, event.Raw.BlockNumber, ) } } }() - sub := dss.Pipe(eventChan) + sub := gts.Pipe(eventChan) return subscription.NewEventSubscription(func() { sub.Unsubscribe() cancelCtx() }) } -func (dss *BDepositsSweptSubscription) Pipe( - sink chan *abi.BridgeDepositsSwept, +func (gts *BGovernanceTransferredSubscription) Pipe( + sink chan *abi.BridgeGovernanceTransferred, ) subscription.EventSubscription { ctx, cancelCtx := context.WithCancel(context.Background()) go func() { - ticker := time.NewTicker(dss.opts.Tick) + ticker := time.NewTicker(gts.opts.Tick) defer ticker.Stop() for { select { case <-ctx.Done(): return case <-ticker.C: - lastBlock, err := dss.contract.blockCounter.CurrentBlock() + lastBlock, err := gts.contract.blockCounter.CurrentBlock() if err != nil { bLogger.Errorf( "subscription failed to pull events: [%v]", err, ) } - fromBlock := lastBlock - dss.opts.PastBlocks + fromBlock := lastBlock - gts.opts.PastBlocks bLogger.Infof( - "subscription monitoring fetching past DepositsSwept events "+ + "subscription monitoring fetching past GovernanceTransferred events "+ "starting from block [%v]", fromBlock, ) - events, err := dss.contract.PastDepositsSweptEvents( + events, err := gts.contract.PastGovernanceTransferredEvents( fromBlock, nil, ) @@ -7700,7 +9521,7 @@ func (dss *BDepositsSweptSubscription) Pipe( continue } bLogger.Infof( - "subscription monitoring fetched [%v] past DepositsSwept events", + "subscription monitoring fetched [%v] past GovernanceTransferred events", len(events), ) @@ -7711,7 +9532,7 @@ func (dss *BDepositsSweptSubscription) Pipe( } }() - sub := dss.contract.watchDepositsSwept( + sub := gts.contract.watchGovernanceTransferred( sink, ) @@ -7721,11 +9542,11 @@ func (dss *BDepositsSweptSubscription) Pipe( }) } -func (b *Bridge) watchDepositsSwept( - sink chan *abi.BridgeDepositsSwept, +func (b *Bridge) watchGovernanceTransferred( + sink chan *abi.BridgeGovernanceTransferred, ) event.Subscription { subscribeFn := func(ctx context.Context) (event.Subscription, error) { - return b.contract.WatchDepositsSwept( + return b.contract.WatchGovernanceTransferred( &bind.WatchOpts{Context: ctx}, sink, ) @@ -7733,7 +9554,7 @@ func (b *Bridge) watchDepositsSwept( thresholdViolatedFn := func(elapsed time.Duration) { bLogger.Warnf( - "subscription to event DepositsSwept had to be "+ + "subscription to event GovernanceTransferred had to be "+ "retried [%s] since the last attempt; please inspect "+ "host chain connectivity", elapsed, @@ -7742,7 +9563,7 @@ func (b *Bridge) watchDepositsSwept( subscriptionFailedFn := func(err error) { bLogger.Errorf( - "subscription to event DepositsSwept failed "+ + "subscription to event GovernanceTransferred failed "+ "with error: [%v]; resubscription attempt will be "+ "performed", err, @@ -7758,11 +9579,11 @@ func (b *Bridge) watchDepositsSwept( ) } -func (b *Bridge) PastDepositsSweptEvents( +func (b *Bridge) PastGovernanceTransferredEvents( startBlock uint64, endBlock *uint64, -) ([]*abi.BridgeDepositsSwept, error) { - iterator, err := b.contract.FilterDepositsSwept( +) ([]*abi.BridgeGovernanceTransferred, error) { + iterator, err := b.contract.FilterGovernanceTransferred( &bind.FilterOpts{ Start: startBlock, End: endBlock, @@ -7770,12 +9591,12 @@ func (b *Bridge) PastDepositsSweptEvents( ) if err != nil { return nil, fmt.Errorf( - "error retrieving past DepositsSwept events: [%v]", + "error retrieving past GovernanceTransferred events: [%v]", err, ) } - events := make([]*abi.BridgeDepositsSwept, 0) + events := make([]*abi.BridgeGovernanceTransferred, 0) for iterator.Next() { event := iterator.Event @@ -7785,10 +9606,9 @@ func (b *Bridge) PastDepositsSweptEvents( return events, nil } -func (b *Bridge) FraudChallengeDefeatTimedOutEvent( +func (b *Bridge) InitializedEvent( opts *ethereum.SubscribeOpts, - walletPubKeyHashFilter [][20]byte, -) *BFraudChallengeDefeatTimedOutSubscription { +) *BInitializedSubscription { if opts == nil { opts = new(ethereum.SubscribeOpts) } @@ -7799,29 +9619,26 @@ func (b *Bridge) FraudChallengeDefeatTimedOutEvent( opts.PastBlocks = chainutil.DefaultSubscribeOptsPastBlocks } - return &BFraudChallengeDefeatTimedOutSubscription{ + return &BInitializedSubscription{ b, opts, - walletPubKeyHashFilter, } } -type BFraudChallengeDefeatTimedOutSubscription struct { - contract *Bridge - opts *ethereum.SubscribeOpts - walletPubKeyHashFilter [][20]byte +type BInitializedSubscription struct { + contract *Bridge + opts *ethereum.SubscribeOpts } -type bridgeFraudChallengeDefeatTimedOutFunc func( - WalletPubKeyHash [20]byte, - Sighash [32]byte, +type bridgeInitializedFunc func( + Version uint8, blockNumber uint64, ) -func (fcdtos *BFraudChallengeDefeatTimedOutSubscription) OnEvent( - handler bridgeFraudChallengeDefeatTimedOutFunc, +func (is *BInitializedSubscription) OnEvent( + handler bridgeInitializedFunc, ) subscription.EventSubscription { - eventChan := make(chan *abi.BridgeFraudChallengeDefeatTimedOut) + eventChan := make(chan *abi.BridgeInitialized) ctx, cancelCtx := context.WithCancel(context.Background()) go func() { @@ -7831,51 +9648,49 @@ func (fcdtos *BFraudChallengeDefeatTimedOutSubscription) OnEvent( return case event := <-eventChan: handler( - event.WalletPubKeyHash, - event.Sighash, + event.Version, event.Raw.BlockNumber, ) } } }() - sub := fcdtos.Pipe(eventChan) + sub := is.Pipe(eventChan) return subscription.NewEventSubscription(func() { sub.Unsubscribe() cancelCtx() }) } -func (fcdtos *BFraudChallengeDefeatTimedOutSubscription) Pipe( - sink chan *abi.BridgeFraudChallengeDefeatTimedOut, +func (is *BInitializedSubscription) Pipe( + sink chan *abi.BridgeInitialized, ) subscription.EventSubscription { ctx, cancelCtx := context.WithCancel(context.Background()) go func() { - ticker := time.NewTicker(fcdtos.opts.Tick) + ticker := time.NewTicker(is.opts.Tick) defer ticker.Stop() for { select { case <-ctx.Done(): return case <-ticker.C: - lastBlock, err := fcdtos.contract.blockCounter.CurrentBlock() + lastBlock, err := is.contract.blockCounter.CurrentBlock() if err != nil { bLogger.Errorf( "subscription failed to pull events: [%v]", err, ) } - fromBlock := lastBlock - fcdtos.opts.PastBlocks + fromBlock := lastBlock - is.opts.PastBlocks bLogger.Infof( - "subscription monitoring fetching past FraudChallengeDefeatTimedOut events "+ + "subscription monitoring fetching past Initialized events "+ "starting from block [%v]", fromBlock, ) - events, err := fcdtos.contract.PastFraudChallengeDefeatTimedOutEvents( + events, err := is.contract.PastInitializedEvents( fromBlock, nil, - fcdtos.walletPubKeyHashFilter, ) if err != nil { bLogger.Errorf( @@ -7885,7 +9700,7 @@ func (fcdtos *BFraudChallengeDefeatTimedOutSubscription) Pipe( continue } bLogger.Infof( - "subscription monitoring fetched [%v] past FraudChallengeDefeatTimedOut events", + "subscription monitoring fetched [%v] past Initialized events", len(events), ) @@ -7896,9 +9711,8 @@ func (fcdtos *BFraudChallengeDefeatTimedOutSubscription) Pipe( } }() - sub := fcdtos.contract.watchFraudChallengeDefeatTimedOut( + sub := is.contract.watchInitialized( sink, - fcdtos.walletPubKeyHashFilter, ) return subscription.NewEventSubscription(func() { @@ -7907,21 +9721,19 @@ func (fcdtos *BFraudChallengeDefeatTimedOutSubscription) Pipe( }) } -func (b *Bridge) watchFraudChallengeDefeatTimedOut( - sink chan *abi.BridgeFraudChallengeDefeatTimedOut, - walletPubKeyHashFilter [][20]byte, +func (b *Bridge) watchInitialized( + sink chan *abi.BridgeInitialized, ) event.Subscription { subscribeFn := func(ctx context.Context) (event.Subscription, error) { - return b.contract.WatchFraudChallengeDefeatTimedOut( + return b.contract.WatchInitialized( &bind.WatchOpts{Context: ctx}, sink, - walletPubKeyHashFilter, ) } thresholdViolatedFn := func(elapsed time.Duration) { bLogger.Warnf( - "subscription to event FraudChallengeDefeatTimedOut had to be "+ + "subscription to event Initialized had to be "+ "retried [%s] since the last attempt; please inspect "+ "host chain connectivity", elapsed, @@ -7930,7 +9742,7 @@ func (b *Bridge) watchFraudChallengeDefeatTimedOut( subscriptionFailedFn := func(err error) { bLogger.Errorf( - "subscription to event FraudChallengeDefeatTimedOut failed "+ + "subscription to event Initialized failed "+ "with error: [%v]; resubscription attempt will be "+ "performed", err, @@ -7946,26 +9758,24 @@ func (b *Bridge) watchFraudChallengeDefeatTimedOut( ) } -func (b *Bridge) PastFraudChallengeDefeatTimedOutEvents( +func (b *Bridge) PastInitializedEvents( startBlock uint64, endBlock *uint64, - walletPubKeyHashFilter [][20]byte, -) ([]*abi.BridgeFraudChallengeDefeatTimedOut, error) { - iterator, err := b.contract.FilterFraudChallengeDefeatTimedOut( +) ([]*abi.BridgeInitialized, error) { + iterator, err := b.contract.FilterInitialized( &bind.FilterOpts{ Start: startBlock, End: endBlock, }, - walletPubKeyHashFilter, ) if err != nil { return nil, fmt.Errorf( - "error retrieving past FraudChallengeDefeatTimedOut events: [%v]", + "error retrieving past Initialized events: [%v]", err, ) } - events := make([]*abi.BridgeFraudChallengeDefeatTimedOut, 0) + events := make([]*abi.BridgeInitialized, 0) for iterator.Next() { event := iterator.Event @@ -7975,10 +9785,12 @@ func (b *Bridge) PastFraudChallengeDefeatTimedOutEvents( return events, nil } -func (b *Bridge) FraudChallengeDefeatedEvent( +func (b *Bridge) LegacyFraudChallengeMigratedEvent( opts *ethereum.SubscribeOpts, - walletPubKeyHashFilter [][20]byte, -) *BFraudChallengeDefeatedSubscription { + routerKindFilter []uint8, + challengeKeyFilter []*big.Int, + challengerFilter []common.Address, +) *BLegacyFraudChallengeMigratedSubscription { if opts == nil { opts = new(ethereum.SubscribeOpts) } @@ -7989,29 +9801,35 @@ func (b *Bridge) FraudChallengeDefeatedEvent( opts.PastBlocks = chainutil.DefaultSubscribeOptsPastBlocks } - return &BFraudChallengeDefeatedSubscription{ + return &BLegacyFraudChallengeMigratedSubscription{ b, opts, - walletPubKeyHashFilter, + routerKindFilter, + challengeKeyFilter, + challengerFilter, } } -type BFraudChallengeDefeatedSubscription struct { - contract *Bridge - opts *ethereum.SubscribeOpts - walletPubKeyHashFilter [][20]byte +type BLegacyFraudChallengeMigratedSubscription struct { + contract *Bridge + opts *ethereum.SubscribeOpts + routerKindFilter []uint8 + challengeKeyFilter []*big.Int + challengerFilter []common.Address } -type bridgeFraudChallengeDefeatedFunc func( - WalletPubKeyHash [20]byte, - Sighash [32]byte, +type bridgeLegacyFraudChallengeMigratedFunc func( + RouterKind uint8, + ChallengeKey *big.Int, + Challenger common.Address, + DepositAmount *big.Int, blockNumber uint64, ) -func (fcds *BFraudChallengeDefeatedSubscription) OnEvent( - handler bridgeFraudChallengeDefeatedFunc, +func (lfcms *BLegacyFraudChallengeMigratedSubscription) OnEvent( + handler bridgeLegacyFraudChallengeMigratedFunc, ) subscription.EventSubscription { - eventChan := make(chan *abi.BridgeFraudChallengeDefeated) + eventChan := make(chan *abi.BridgeLegacyFraudChallengeMigrated) ctx, cancelCtx := context.WithCancel(context.Background()) go func() { @@ -8021,51 +9839,55 @@ func (fcds *BFraudChallengeDefeatedSubscription) OnEvent( return case event := <-eventChan: handler( - event.WalletPubKeyHash, - event.Sighash, + event.RouterKind, + event.ChallengeKey, + event.Challenger, + event.DepositAmount, event.Raw.BlockNumber, ) } } }() - sub := fcds.Pipe(eventChan) + sub := lfcms.Pipe(eventChan) return subscription.NewEventSubscription(func() { sub.Unsubscribe() cancelCtx() }) } -func (fcds *BFraudChallengeDefeatedSubscription) Pipe( - sink chan *abi.BridgeFraudChallengeDefeated, +func (lfcms *BLegacyFraudChallengeMigratedSubscription) Pipe( + sink chan *abi.BridgeLegacyFraudChallengeMigrated, ) subscription.EventSubscription { ctx, cancelCtx := context.WithCancel(context.Background()) go func() { - ticker := time.NewTicker(fcds.opts.Tick) + ticker := time.NewTicker(lfcms.opts.Tick) defer ticker.Stop() for { select { case <-ctx.Done(): return case <-ticker.C: - lastBlock, err := fcds.contract.blockCounter.CurrentBlock() + lastBlock, err := lfcms.contract.blockCounter.CurrentBlock() if err != nil { bLogger.Errorf( "subscription failed to pull events: [%v]", err, ) } - fromBlock := lastBlock - fcds.opts.PastBlocks + fromBlock := lastBlock - lfcms.opts.PastBlocks bLogger.Infof( - "subscription monitoring fetching past FraudChallengeDefeated events "+ + "subscription monitoring fetching past LegacyFraudChallengeMigrated events "+ "starting from block [%v]", fromBlock, ) - events, err := fcds.contract.PastFraudChallengeDefeatedEvents( + events, err := lfcms.contract.PastLegacyFraudChallengeMigratedEvents( fromBlock, nil, - fcds.walletPubKeyHashFilter, + lfcms.routerKindFilter, + lfcms.challengeKeyFilter, + lfcms.challengerFilter, ) if err != nil { bLogger.Errorf( @@ -8075,7 +9897,7 @@ func (fcds *BFraudChallengeDefeatedSubscription) Pipe( continue } bLogger.Infof( - "subscription monitoring fetched [%v] past FraudChallengeDefeated events", + "subscription monitoring fetched [%v] past LegacyFraudChallengeMigrated events", len(events), ) @@ -8086,9 +9908,11 @@ func (fcds *BFraudChallengeDefeatedSubscription) Pipe( } }() - sub := fcds.contract.watchFraudChallengeDefeated( + sub := lfcms.contract.watchLegacyFraudChallengeMigrated( sink, - fcds.walletPubKeyHashFilter, + lfcms.routerKindFilter, + lfcms.challengeKeyFilter, + lfcms.challengerFilter, ) return subscription.NewEventSubscription(func() { @@ -8097,21 +9921,25 @@ func (fcds *BFraudChallengeDefeatedSubscription) Pipe( }) } -func (b *Bridge) watchFraudChallengeDefeated( - sink chan *abi.BridgeFraudChallengeDefeated, - walletPubKeyHashFilter [][20]byte, +func (b *Bridge) watchLegacyFraudChallengeMigrated( + sink chan *abi.BridgeLegacyFraudChallengeMigrated, + routerKindFilter []uint8, + challengeKeyFilter []*big.Int, + challengerFilter []common.Address, ) event.Subscription { subscribeFn := func(ctx context.Context) (event.Subscription, error) { - return b.contract.WatchFraudChallengeDefeated( + return b.contract.WatchLegacyFraudChallengeMigrated( &bind.WatchOpts{Context: ctx}, sink, - walletPubKeyHashFilter, + routerKindFilter, + challengeKeyFilter, + challengerFilter, ) } thresholdViolatedFn := func(elapsed time.Duration) { bLogger.Warnf( - "subscription to event FraudChallengeDefeated had to be "+ + "subscription to event LegacyFraudChallengeMigrated had to be "+ "retried [%s] since the last attempt; please inspect "+ "host chain connectivity", elapsed, @@ -8120,7 +9948,7 @@ func (b *Bridge) watchFraudChallengeDefeated( subscriptionFailedFn := func(err error) { bLogger.Errorf( - "subscription to event FraudChallengeDefeated failed "+ + "subscription to event LegacyFraudChallengeMigrated failed "+ "with error: [%v]; resubscription attempt will be "+ "performed", err, @@ -8136,26 +9964,30 @@ func (b *Bridge) watchFraudChallengeDefeated( ) } -func (b *Bridge) PastFraudChallengeDefeatedEvents( +func (b *Bridge) PastLegacyFraudChallengeMigratedEvents( startBlock uint64, endBlock *uint64, - walletPubKeyHashFilter [][20]byte, -) ([]*abi.BridgeFraudChallengeDefeated, error) { - iterator, err := b.contract.FilterFraudChallengeDefeated( + routerKindFilter []uint8, + challengeKeyFilter []*big.Int, + challengerFilter []common.Address, +) ([]*abi.BridgeLegacyFraudChallengeMigrated, error) { + iterator, err := b.contract.FilterLegacyFraudChallengeMigrated( &bind.FilterOpts{ Start: startBlock, End: endBlock, }, - walletPubKeyHashFilter, + routerKindFilter, + challengeKeyFilter, + challengerFilter, ) if err != nil { return nil, fmt.Errorf( - "error retrieving past FraudChallengeDefeated events: [%v]", + "error retrieving past LegacyFraudChallengeMigrated events: [%v]", err, ) } - events := make([]*abi.BridgeFraudChallengeDefeated, 0) + events := make([]*abi.BridgeLegacyFraudChallengeMigrated, 0) for iterator.Next() { event := iterator.Event @@ -8165,10 +9997,9 @@ func (b *Bridge) PastFraudChallengeDefeatedEvents( return events, nil } -func (b *Bridge) FraudChallengeSubmittedEvent( +func (b *Bridge) LifecycleRouterSetEvent( opts *ethereum.SubscribeOpts, - walletPubKeyHashFilter [][20]byte, -) *BFraudChallengeSubmittedSubscription { +) *BLifecycleRouterSetSubscription { if opts == nil { opts = new(ethereum.SubscribeOpts) } @@ -8179,32 +10010,26 @@ func (b *Bridge) FraudChallengeSubmittedEvent( opts.PastBlocks = chainutil.DefaultSubscribeOptsPastBlocks } - return &BFraudChallengeSubmittedSubscription{ + return &BLifecycleRouterSetSubscription{ b, opts, - walletPubKeyHashFilter, } } -type BFraudChallengeSubmittedSubscription struct { - contract *Bridge - opts *ethereum.SubscribeOpts - walletPubKeyHashFilter [][20]byte +type BLifecycleRouterSetSubscription struct { + contract *Bridge + opts *ethereum.SubscribeOpts } -type bridgeFraudChallengeSubmittedFunc func( - WalletPubKeyHash [20]byte, - Sighash [32]byte, - V uint8, - R [32]byte, - S [32]byte, +type bridgeLifecycleRouterSetFunc func( + LifecycleRouter common.Address, blockNumber uint64, ) -func (fcss *BFraudChallengeSubmittedSubscription) OnEvent( - handler bridgeFraudChallengeSubmittedFunc, +func (lrss *BLifecycleRouterSetSubscription) OnEvent( + handler bridgeLifecycleRouterSetFunc, ) subscription.EventSubscription { - eventChan := make(chan *abi.BridgeFraudChallengeSubmitted) + eventChan := make(chan *abi.BridgeLifecycleRouterSet) ctx, cancelCtx := context.WithCancel(context.Background()) go func() { @@ -8214,54 +10039,49 @@ func (fcss *BFraudChallengeSubmittedSubscription) OnEvent( return case event := <-eventChan: handler( - event.WalletPubKeyHash, - event.Sighash, - event.V, - event.R, - event.S, + event.LifecycleRouter, event.Raw.BlockNumber, ) } } }() - sub := fcss.Pipe(eventChan) + sub := lrss.Pipe(eventChan) return subscription.NewEventSubscription(func() { sub.Unsubscribe() cancelCtx() }) } -func (fcss *BFraudChallengeSubmittedSubscription) Pipe( - sink chan *abi.BridgeFraudChallengeSubmitted, +func (lrss *BLifecycleRouterSetSubscription) Pipe( + sink chan *abi.BridgeLifecycleRouterSet, ) subscription.EventSubscription { ctx, cancelCtx := context.WithCancel(context.Background()) go func() { - ticker := time.NewTicker(fcss.opts.Tick) + ticker := time.NewTicker(lrss.opts.Tick) defer ticker.Stop() for { select { case <-ctx.Done(): return case <-ticker.C: - lastBlock, err := fcss.contract.blockCounter.CurrentBlock() + lastBlock, err := lrss.contract.blockCounter.CurrentBlock() if err != nil { bLogger.Errorf( "subscription failed to pull events: [%v]", err, ) } - fromBlock := lastBlock - fcss.opts.PastBlocks + fromBlock := lastBlock - lrss.opts.PastBlocks bLogger.Infof( - "subscription monitoring fetching past FraudChallengeSubmitted events "+ + "subscription monitoring fetching past LifecycleRouterSet events "+ "starting from block [%v]", fromBlock, ) - events, err := fcss.contract.PastFraudChallengeSubmittedEvents( + events, err := lrss.contract.PastLifecycleRouterSetEvents( fromBlock, nil, - fcss.walletPubKeyHashFilter, ) if err != nil { bLogger.Errorf( @@ -8271,7 +10091,7 @@ func (fcss *BFraudChallengeSubmittedSubscription) Pipe( continue } bLogger.Infof( - "subscription monitoring fetched [%v] past FraudChallengeSubmitted events", + "subscription monitoring fetched [%v] past LifecycleRouterSet events", len(events), ) @@ -8282,9 +10102,8 @@ func (fcss *BFraudChallengeSubmittedSubscription) Pipe( } }() - sub := fcss.contract.watchFraudChallengeSubmitted( + sub := lrss.contract.watchLifecycleRouterSet( sink, - fcss.walletPubKeyHashFilter, ) return subscription.NewEventSubscription(func() { @@ -8293,21 +10112,19 @@ func (fcss *BFraudChallengeSubmittedSubscription) Pipe( }) } -func (b *Bridge) watchFraudChallengeSubmitted( - sink chan *abi.BridgeFraudChallengeSubmitted, - walletPubKeyHashFilter [][20]byte, +func (b *Bridge) watchLifecycleRouterSet( + sink chan *abi.BridgeLifecycleRouterSet, ) event.Subscription { subscribeFn := func(ctx context.Context) (event.Subscription, error) { - return b.contract.WatchFraudChallengeSubmitted( + return b.contract.WatchLifecycleRouterSet( &bind.WatchOpts{Context: ctx}, sink, - walletPubKeyHashFilter, ) } thresholdViolatedFn := func(elapsed time.Duration) { bLogger.Warnf( - "subscription to event FraudChallengeSubmitted had to be "+ + "subscription to event LifecycleRouterSet had to be "+ "retried [%s] since the last attempt; please inspect "+ "host chain connectivity", elapsed, @@ -8316,7 +10133,7 @@ func (b *Bridge) watchFraudChallengeSubmitted( subscriptionFailedFn := func(err error) { bLogger.Errorf( - "subscription to event FraudChallengeSubmitted failed "+ + "subscription to event LifecycleRouterSet failed "+ "with error: [%v]; resubscription attempt will be "+ "performed", err, @@ -8332,26 +10149,24 @@ func (b *Bridge) watchFraudChallengeSubmitted( ) } -func (b *Bridge) PastFraudChallengeSubmittedEvents( +func (b *Bridge) PastLifecycleRouterSetEvents( startBlock uint64, endBlock *uint64, - walletPubKeyHashFilter [][20]byte, -) ([]*abi.BridgeFraudChallengeSubmitted, error) { - iterator, err := b.contract.FilterFraudChallengeSubmitted( +) ([]*abi.BridgeLifecycleRouterSet, error) { + iterator, err := b.contract.FilterLifecycleRouterSet( &bind.FilterOpts{ Start: startBlock, End: endBlock, }, - walletPubKeyHashFilter, ) if err != nil { return nil, fmt.Errorf( - "error retrieving past FraudChallengeSubmitted events: [%v]", + "error retrieving past LifecycleRouterSet events: [%v]", err, ) } - events := make([]*abi.BridgeFraudChallengeSubmitted, 0) + events := make([]*abi.BridgeLifecycleRouterSet, 0) for iterator.Next() { event := iterator.Event @@ -8361,9 +10176,10 @@ func (b *Bridge) PastFraudChallengeSubmittedEvents( return events, nil } -func (b *Bridge) FraudParametersUpdatedEvent( +func (b *Bridge) MovedFundsSweepTimedOutEvent( opts *ethereum.SubscribeOpts, -) *BFraudParametersUpdatedSubscription { + walletPubKeyHashFilter [][20]byte, +) *BMovedFundsSweepTimedOutSubscription { if opts == nil { opts = new(ethereum.SubscribeOpts) } @@ -8374,29 +10190,30 @@ func (b *Bridge) FraudParametersUpdatedEvent( opts.PastBlocks = chainutil.DefaultSubscribeOptsPastBlocks } - return &BFraudParametersUpdatedSubscription{ + return &BMovedFundsSweepTimedOutSubscription{ b, opts, + walletPubKeyHashFilter, } } -type BFraudParametersUpdatedSubscription struct { - contract *Bridge - opts *ethereum.SubscribeOpts +type BMovedFundsSweepTimedOutSubscription struct { + contract *Bridge + opts *ethereum.SubscribeOpts + walletPubKeyHashFilter [][20]byte } -type bridgeFraudParametersUpdatedFunc func( - FraudChallengeDepositAmount *big.Int, - FraudChallengeDefeatTimeout uint32, - FraudSlashingAmount *big.Int, - FraudNotifierRewardMultiplier uint32, +type bridgeMovedFundsSweepTimedOutFunc func( + WalletPubKeyHash [20]byte, + MovingFundsTxHash [32]byte, + MovingFundsTxOutputIndex uint32, blockNumber uint64, ) -func (fpus *BFraudParametersUpdatedSubscription) OnEvent( - handler bridgeFraudParametersUpdatedFunc, +func (mfstos *BMovedFundsSweepTimedOutSubscription) OnEvent( + handler bridgeMovedFundsSweepTimedOutFunc, ) subscription.EventSubscription { - eventChan := make(chan *abi.BridgeFraudParametersUpdated) + eventChan := make(chan *abi.BridgeMovedFundsSweepTimedOut) ctx, cancelCtx := context.WithCancel(context.Background()) go func() { @@ -8406,52 +10223,52 @@ func (fpus *BFraudParametersUpdatedSubscription) OnEvent( return case event := <-eventChan: handler( - event.FraudChallengeDepositAmount, - event.FraudChallengeDefeatTimeout, - event.FraudSlashingAmount, - event.FraudNotifierRewardMultiplier, + event.WalletPubKeyHash, + event.MovingFundsTxHash, + event.MovingFundsTxOutputIndex, event.Raw.BlockNumber, ) } } }() - sub := fpus.Pipe(eventChan) + sub := mfstos.Pipe(eventChan) return subscription.NewEventSubscription(func() { sub.Unsubscribe() cancelCtx() }) } -func (fpus *BFraudParametersUpdatedSubscription) Pipe( - sink chan *abi.BridgeFraudParametersUpdated, +func (mfstos *BMovedFundsSweepTimedOutSubscription) Pipe( + sink chan *abi.BridgeMovedFundsSweepTimedOut, ) subscription.EventSubscription { ctx, cancelCtx := context.WithCancel(context.Background()) go func() { - ticker := time.NewTicker(fpus.opts.Tick) + ticker := time.NewTicker(mfstos.opts.Tick) defer ticker.Stop() for { select { case <-ctx.Done(): return case <-ticker.C: - lastBlock, err := fpus.contract.blockCounter.CurrentBlock() + lastBlock, err := mfstos.contract.blockCounter.CurrentBlock() if err != nil { bLogger.Errorf( "subscription failed to pull events: [%v]", err, ) } - fromBlock := lastBlock - fpus.opts.PastBlocks + fromBlock := lastBlock - mfstos.opts.PastBlocks bLogger.Infof( - "subscription monitoring fetching past FraudParametersUpdated events "+ + "subscription monitoring fetching past MovedFundsSweepTimedOut events "+ "starting from block [%v]", fromBlock, ) - events, err := fpus.contract.PastFraudParametersUpdatedEvents( + events, err := mfstos.contract.PastMovedFundsSweepTimedOutEvents( fromBlock, nil, + mfstos.walletPubKeyHashFilter, ) if err != nil { bLogger.Errorf( @@ -8461,7 +10278,7 @@ func (fpus *BFraudParametersUpdatedSubscription) Pipe( continue } bLogger.Infof( - "subscription monitoring fetched [%v] past FraudParametersUpdated events", + "subscription monitoring fetched [%v] past MovedFundsSweepTimedOut events", len(events), ) @@ -8472,8 +10289,9 @@ func (fpus *BFraudParametersUpdatedSubscription) Pipe( } }() - sub := fpus.contract.watchFraudParametersUpdated( + sub := mfstos.contract.watchMovedFundsSweepTimedOut( sink, + mfstos.walletPubKeyHashFilter, ) return subscription.NewEventSubscription(func() { @@ -8482,19 +10300,21 @@ func (fpus *BFraudParametersUpdatedSubscription) Pipe( }) } -func (b *Bridge) watchFraudParametersUpdated( - sink chan *abi.BridgeFraudParametersUpdated, +func (b *Bridge) watchMovedFundsSweepTimedOut( + sink chan *abi.BridgeMovedFundsSweepTimedOut, + walletPubKeyHashFilter [][20]byte, ) event.Subscription { subscribeFn := func(ctx context.Context) (event.Subscription, error) { - return b.contract.WatchFraudParametersUpdated( + return b.contract.WatchMovedFundsSweepTimedOut( &bind.WatchOpts{Context: ctx}, sink, + walletPubKeyHashFilter, ) } thresholdViolatedFn := func(elapsed time.Duration) { bLogger.Warnf( - "subscription to event FraudParametersUpdated had to be "+ + "subscription to event MovedFundsSweepTimedOut had to be "+ "retried [%s] since the last attempt; please inspect "+ "host chain connectivity", elapsed, @@ -8503,7 +10323,7 @@ func (b *Bridge) watchFraudParametersUpdated( subscriptionFailedFn := func(err error) { bLogger.Errorf( - "subscription to event FraudParametersUpdated failed "+ + "subscription to event MovedFundsSweepTimedOut failed "+ "with error: [%v]; resubscription attempt will be "+ "performed", err, @@ -8519,24 +10339,26 @@ func (b *Bridge) watchFraudParametersUpdated( ) } -func (b *Bridge) PastFraudParametersUpdatedEvents( +func (b *Bridge) PastMovedFundsSweepTimedOutEvents( startBlock uint64, endBlock *uint64, -) ([]*abi.BridgeFraudParametersUpdated, error) { - iterator, err := b.contract.FilterFraudParametersUpdated( + walletPubKeyHashFilter [][20]byte, +) ([]*abi.BridgeMovedFundsSweepTimedOut, error) { + iterator, err := b.contract.FilterMovedFundsSweepTimedOut( &bind.FilterOpts{ Start: startBlock, End: endBlock, }, + walletPubKeyHashFilter, ) if err != nil { return nil, fmt.Errorf( - "error retrieving past FraudParametersUpdated events: [%v]", + "error retrieving past MovedFundsSweepTimedOut events: [%v]", err, ) } - events := make([]*abi.BridgeFraudParametersUpdated, 0) + events := make([]*abi.BridgeMovedFundsSweepTimedOut, 0) for iterator.Next() { event := iterator.Event @@ -8546,9 +10368,10 @@ func (b *Bridge) PastFraudParametersUpdatedEvents( return events, nil } -func (b *Bridge) GovernanceTransferredEvent( +func (b *Bridge) MovedFundsSweptEvent( opts *ethereum.SubscribeOpts, -) *BGovernanceTransferredSubscription { + walletPubKeyHashFilter [][20]byte, +) *BMovedFundsSweptSubscription { if opts == nil { opts = new(ethereum.SubscribeOpts) } @@ -8559,27 +10382,29 @@ func (b *Bridge) GovernanceTransferredEvent( opts.PastBlocks = chainutil.DefaultSubscribeOptsPastBlocks } - return &BGovernanceTransferredSubscription{ + return &BMovedFundsSweptSubscription{ b, opts, + walletPubKeyHashFilter, } } -type BGovernanceTransferredSubscription struct { - contract *Bridge - opts *ethereum.SubscribeOpts +type BMovedFundsSweptSubscription struct { + contract *Bridge + opts *ethereum.SubscribeOpts + walletPubKeyHashFilter [][20]byte } -type bridgeGovernanceTransferredFunc func( - OldGovernance common.Address, - NewGovernance common.Address, +type bridgeMovedFundsSweptFunc func( + WalletPubKeyHash [20]byte, + SweepTxHash [32]byte, blockNumber uint64, ) -func (gts *BGovernanceTransferredSubscription) OnEvent( - handler bridgeGovernanceTransferredFunc, +func (mfss *BMovedFundsSweptSubscription) OnEvent( + handler bridgeMovedFundsSweptFunc, ) subscription.EventSubscription { - eventChan := make(chan *abi.BridgeGovernanceTransferred) + eventChan := make(chan *abi.BridgeMovedFundsSwept) ctx, cancelCtx := context.WithCancel(context.Background()) go func() { @@ -8589,50 +10414,51 @@ func (gts *BGovernanceTransferredSubscription) OnEvent( return case event := <-eventChan: handler( - event.OldGovernance, - event.NewGovernance, + event.WalletPubKeyHash, + event.SweepTxHash, event.Raw.BlockNumber, ) } } }() - sub := gts.Pipe(eventChan) + sub := mfss.Pipe(eventChan) return subscription.NewEventSubscription(func() { sub.Unsubscribe() cancelCtx() }) } -func (gts *BGovernanceTransferredSubscription) Pipe( - sink chan *abi.BridgeGovernanceTransferred, +func (mfss *BMovedFundsSweptSubscription) Pipe( + sink chan *abi.BridgeMovedFundsSwept, ) subscription.EventSubscription { ctx, cancelCtx := context.WithCancel(context.Background()) go func() { - ticker := time.NewTicker(gts.opts.Tick) + ticker := time.NewTicker(mfss.opts.Tick) defer ticker.Stop() for { select { case <-ctx.Done(): return case <-ticker.C: - lastBlock, err := gts.contract.blockCounter.CurrentBlock() + lastBlock, err := mfss.contract.blockCounter.CurrentBlock() if err != nil { bLogger.Errorf( "subscription failed to pull events: [%v]", err, ) } - fromBlock := lastBlock - gts.opts.PastBlocks + fromBlock := lastBlock - mfss.opts.PastBlocks bLogger.Infof( - "subscription monitoring fetching past GovernanceTransferred events "+ + "subscription monitoring fetching past MovedFundsSwept events "+ "starting from block [%v]", fromBlock, ) - events, err := gts.contract.PastGovernanceTransferredEvents( + events, err := mfss.contract.PastMovedFundsSweptEvents( fromBlock, nil, + mfss.walletPubKeyHashFilter, ) if err != nil { bLogger.Errorf( @@ -8642,7 +10468,7 @@ func (gts *BGovernanceTransferredSubscription) Pipe( continue } bLogger.Infof( - "subscription monitoring fetched [%v] past GovernanceTransferred events", + "subscription monitoring fetched [%v] past MovedFundsSwept events", len(events), ) @@ -8653,8 +10479,9 @@ func (gts *BGovernanceTransferredSubscription) Pipe( } }() - sub := gts.contract.watchGovernanceTransferred( + sub := mfss.contract.watchMovedFundsSwept( sink, + mfss.walletPubKeyHashFilter, ) return subscription.NewEventSubscription(func() { @@ -8663,19 +10490,21 @@ func (gts *BGovernanceTransferredSubscription) Pipe( }) } -func (b *Bridge) watchGovernanceTransferred( - sink chan *abi.BridgeGovernanceTransferred, +func (b *Bridge) watchMovedFundsSwept( + sink chan *abi.BridgeMovedFundsSwept, + walletPubKeyHashFilter [][20]byte, ) event.Subscription { subscribeFn := func(ctx context.Context) (event.Subscription, error) { - return b.contract.WatchGovernanceTransferred( + return b.contract.WatchMovedFundsSwept( &bind.WatchOpts{Context: ctx}, sink, + walletPubKeyHashFilter, ) } thresholdViolatedFn := func(elapsed time.Duration) { bLogger.Warnf( - "subscription to event GovernanceTransferred had to be "+ + "subscription to event MovedFundsSwept had to be "+ "retried [%s] since the last attempt; please inspect "+ "host chain connectivity", elapsed, @@ -8684,7 +10513,7 @@ func (b *Bridge) watchGovernanceTransferred( subscriptionFailedFn := func(err error) { bLogger.Errorf( - "subscription to event GovernanceTransferred failed "+ + "subscription to event MovedFundsSwept failed "+ "with error: [%v]; resubscription attempt will be "+ "performed", err, @@ -8700,24 +10529,26 @@ func (b *Bridge) watchGovernanceTransferred( ) } -func (b *Bridge) PastGovernanceTransferredEvents( +func (b *Bridge) PastMovedFundsSweptEvents( startBlock uint64, endBlock *uint64, -) ([]*abi.BridgeGovernanceTransferred, error) { - iterator, err := b.contract.FilterGovernanceTransferred( + walletPubKeyHashFilter [][20]byte, +) ([]*abi.BridgeMovedFundsSwept, error) { + iterator, err := b.contract.FilterMovedFundsSwept( &bind.FilterOpts{ Start: startBlock, End: endBlock, }, + walletPubKeyHashFilter, ) if err != nil { return nil, fmt.Errorf( - "error retrieving past GovernanceTransferred events: [%v]", + "error retrieving past MovedFundsSwept events: [%v]", err, ) } - events := make([]*abi.BridgeGovernanceTransferred, 0) + events := make([]*abi.BridgeMovedFundsSwept, 0) for iterator.Next() { event := iterator.Event @@ -8727,9 +10558,10 @@ func (b *Bridge) PastGovernanceTransferredEvents( return events, nil } -func (b *Bridge) InitializedEvent( +func (b *Bridge) MovingFundsBelowDustReportedEvent( opts *ethereum.SubscribeOpts, -) *BInitializedSubscription { + walletPubKeyHashFilter [][20]byte, +) *BMovingFundsBelowDustReportedSubscription { if opts == nil { opts = new(ethereum.SubscribeOpts) } @@ -8740,26 +10572,28 @@ func (b *Bridge) InitializedEvent( opts.PastBlocks = chainutil.DefaultSubscribeOptsPastBlocks } - return &BInitializedSubscription{ + return &BMovingFundsBelowDustReportedSubscription{ b, opts, + walletPubKeyHashFilter, } } -type BInitializedSubscription struct { - contract *Bridge - opts *ethereum.SubscribeOpts +type BMovingFundsBelowDustReportedSubscription struct { + contract *Bridge + opts *ethereum.SubscribeOpts + walletPubKeyHashFilter [][20]byte } -type bridgeInitializedFunc func( - Version uint8, +type bridgeMovingFundsBelowDustReportedFunc func( + WalletPubKeyHash [20]byte, blockNumber uint64, ) -func (is *BInitializedSubscription) OnEvent( - handler bridgeInitializedFunc, +func (mfbdrs *BMovingFundsBelowDustReportedSubscription) OnEvent( + handler bridgeMovingFundsBelowDustReportedFunc, ) subscription.EventSubscription { - eventChan := make(chan *abi.BridgeInitialized) + eventChan := make(chan *abi.BridgeMovingFundsBelowDustReported) ctx, cancelCtx := context.WithCancel(context.Background()) go func() { @@ -8769,49 +10603,50 @@ func (is *BInitializedSubscription) OnEvent( return case event := <-eventChan: handler( - event.Version, + event.WalletPubKeyHash, event.Raw.BlockNumber, ) } } }() - sub := is.Pipe(eventChan) + sub := mfbdrs.Pipe(eventChan) return subscription.NewEventSubscription(func() { sub.Unsubscribe() cancelCtx() }) } -func (is *BInitializedSubscription) Pipe( - sink chan *abi.BridgeInitialized, +func (mfbdrs *BMovingFundsBelowDustReportedSubscription) Pipe( + sink chan *abi.BridgeMovingFundsBelowDustReported, ) subscription.EventSubscription { ctx, cancelCtx := context.WithCancel(context.Background()) go func() { - ticker := time.NewTicker(is.opts.Tick) + ticker := time.NewTicker(mfbdrs.opts.Tick) defer ticker.Stop() for { select { case <-ctx.Done(): return case <-ticker.C: - lastBlock, err := is.contract.blockCounter.CurrentBlock() + lastBlock, err := mfbdrs.contract.blockCounter.CurrentBlock() if err != nil { bLogger.Errorf( "subscription failed to pull events: [%v]", err, ) } - fromBlock := lastBlock - is.opts.PastBlocks + fromBlock := lastBlock - mfbdrs.opts.PastBlocks bLogger.Infof( - "subscription monitoring fetching past Initialized events "+ + "subscription monitoring fetching past MovingFundsBelowDustReported events "+ "starting from block [%v]", fromBlock, ) - events, err := is.contract.PastInitializedEvents( + events, err := mfbdrs.contract.PastMovingFundsBelowDustReportedEvents( fromBlock, nil, + mfbdrs.walletPubKeyHashFilter, ) if err != nil { bLogger.Errorf( @@ -8821,7 +10656,7 @@ func (is *BInitializedSubscription) Pipe( continue } bLogger.Infof( - "subscription monitoring fetched [%v] past Initialized events", + "subscription monitoring fetched [%v] past MovingFundsBelowDustReported events", len(events), ) @@ -8832,8 +10667,9 @@ func (is *BInitializedSubscription) Pipe( } }() - sub := is.contract.watchInitialized( + sub := mfbdrs.contract.watchMovingFundsBelowDustReported( sink, + mfbdrs.walletPubKeyHashFilter, ) return subscription.NewEventSubscription(func() { @@ -8842,19 +10678,21 @@ func (is *BInitializedSubscription) Pipe( }) } -func (b *Bridge) watchInitialized( - sink chan *abi.BridgeInitialized, +func (b *Bridge) watchMovingFundsBelowDustReported( + sink chan *abi.BridgeMovingFundsBelowDustReported, + walletPubKeyHashFilter [][20]byte, ) event.Subscription { subscribeFn := func(ctx context.Context) (event.Subscription, error) { - return b.contract.WatchInitialized( + return b.contract.WatchMovingFundsBelowDustReported( &bind.WatchOpts{Context: ctx}, sink, + walletPubKeyHashFilter, ) } thresholdViolatedFn := func(elapsed time.Duration) { bLogger.Warnf( - "subscription to event Initialized had to be "+ + "subscription to event MovingFundsBelowDustReported had to be "+ "retried [%s] since the last attempt; please inspect "+ "host chain connectivity", elapsed, @@ -8863,7 +10701,7 @@ func (b *Bridge) watchInitialized( subscriptionFailedFn := func(err error) { bLogger.Errorf( - "subscription to event Initialized failed "+ + "subscription to event MovingFundsBelowDustReported failed "+ "with error: [%v]; resubscription attempt will be "+ "performed", err, @@ -8879,24 +10717,26 @@ func (b *Bridge) watchInitialized( ) } -func (b *Bridge) PastInitializedEvents( +func (b *Bridge) PastMovingFundsBelowDustReportedEvents( startBlock uint64, endBlock *uint64, -) ([]*abi.BridgeInitialized, error) { - iterator, err := b.contract.FilterInitialized( + walletPubKeyHashFilter [][20]byte, +) ([]*abi.BridgeMovingFundsBelowDustReported, error) { + iterator, err := b.contract.FilterMovingFundsBelowDustReported( &bind.FilterOpts{ Start: startBlock, End: endBlock, }, + walletPubKeyHashFilter, ) if err != nil { return nil, fmt.Errorf( - "error retrieving past Initialized events: [%v]", + "error retrieving past MovingFundsBelowDustReported events: [%v]", err, ) } - events := make([]*abi.BridgeInitialized, 0) + events := make([]*abi.BridgeMovingFundsBelowDustReported, 0) for iterator.Next() { event := iterator.Event @@ -8906,10 +10746,10 @@ func (b *Bridge) PastInitializedEvents( return events, nil } -func (b *Bridge) MovedFundsSweepTimedOutEvent( +func (b *Bridge) MovingFundsCommitmentSubmittedEvent( opts *ethereum.SubscribeOpts, walletPubKeyHashFilter [][20]byte, -) *BMovedFundsSweepTimedOutSubscription { +) *BMovingFundsCommitmentSubmittedSubscription { if opts == nil { opts = new(ethereum.SubscribeOpts) } @@ -8920,30 +10760,30 @@ func (b *Bridge) MovedFundsSweepTimedOutEvent( opts.PastBlocks = chainutil.DefaultSubscribeOptsPastBlocks } - return &BMovedFundsSweepTimedOutSubscription{ + return &BMovingFundsCommitmentSubmittedSubscription{ b, opts, walletPubKeyHashFilter, } } -type BMovedFundsSweepTimedOutSubscription struct { +type BMovingFundsCommitmentSubmittedSubscription struct { contract *Bridge opts *ethereum.SubscribeOpts walletPubKeyHashFilter [][20]byte } -type bridgeMovedFundsSweepTimedOutFunc func( +type bridgeMovingFundsCommitmentSubmittedFunc func( WalletPubKeyHash [20]byte, - MovingFundsTxHash [32]byte, - MovingFundsTxOutputIndex uint32, + TargetWallets [][20]byte, + Submitter common.Address, blockNumber uint64, ) -func (mfstos *BMovedFundsSweepTimedOutSubscription) OnEvent( - handler bridgeMovedFundsSweepTimedOutFunc, +func (mfcss *BMovingFundsCommitmentSubmittedSubscription) OnEvent( + handler bridgeMovingFundsCommitmentSubmittedFunc, ) subscription.EventSubscription { - eventChan := make(chan *abi.BridgeMovedFundsSweepTimedOut) + eventChan := make(chan *abi.BridgeMovingFundsCommitmentSubmitted) ctx, cancelCtx := context.WithCancel(context.Background()) go func() { @@ -8954,51 +10794,51 @@ func (mfstos *BMovedFundsSweepTimedOutSubscription) OnEvent( case event := <-eventChan: handler( event.WalletPubKeyHash, - event.MovingFundsTxHash, - event.MovingFundsTxOutputIndex, + event.TargetWallets, + event.Submitter, event.Raw.BlockNumber, ) } } }() - sub := mfstos.Pipe(eventChan) + sub := mfcss.Pipe(eventChan) return subscription.NewEventSubscription(func() { sub.Unsubscribe() cancelCtx() }) } -func (mfstos *BMovedFundsSweepTimedOutSubscription) Pipe( - sink chan *abi.BridgeMovedFundsSweepTimedOut, +func (mfcss *BMovingFundsCommitmentSubmittedSubscription) Pipe( + sink chan *abi.BridgeMovingFundsCommitmentSubmitted, ) subscription.EventSubscription { ctx, cancelCtx := context.WithCancel(context.Background()) go func() { - ticker := time.NewTicker(mfstos.opts.Tick) + ticker := time.NewTicker(mfcss.opts.Tick) defer ticker.Stop() for { select { case <-ctx.Done(): return case <-ticker.C: - lastBlock, err := mfstos.contract.blockCounter.CurrentBlock() + lastBlock, err := mfcss.contract.blockCounter.CurrentBlock() if err != nil { bLogger.Errorf( "subscription failed to pull events: [%v]", err, ) } - fromBlock := lastBlock - mfstos.opts.PastBlocks + fromBlock := lastBlock - mfcss.opts.PastBlocks bLogger.Infof( - "subscription monitoring fetching past MovedFundsSweepTimedOut events "+ + "subscription monitoring fetching past MovingFundsCommitmentSubmitted events "+ "starting from block [%v]", fromBlock, ) - events, err := mfstos.contract.PastMovedFundsSweepTimedOutEvents( + events, err := mfcss.contract.PastMovingFundsCommitmentSubmittedEvents( fromBlock, nil, - mfstos.walletPubKeyHashFilter, + mfcss.walletPubKeyHashFilter, ) if err != nil { bLogger.Errorf( @@ -9008,7 +10848,7 @@ func (mfstos *BMovedFundsSweepTimedOutSubscription) Pipe( continue } bLogger.Infof( - "subscription monitoring fetched [%v] past MovedFundsSweepTimedOut events", + "subscription monitoring fetched [%v] past MovingFundsCommitmentSubmitted events", len(events), ) @@ -9019,9 +10859,9 @@ func (mfstos *BMovedFundsSweepTimedOutSubscription) Pipe( } }() - sub := mfstos.contract.watchMovedFundsSweepTimedOut( + sub := mfcss.contract.watchMovingFundsCommitmentSubmitted( sink, - mfstos.walletPubKeyHashFilter, + mfcss.walletPubKeyHashFilter, ) return subscription.NewEventSubscription(func() { @@ -9030,12 +10870,12 @@ func (mfstos *BMovedFundsSweepTimedOutSubscription) Pipe( }) } -func (b *Bridge) watchMovedFundsSweepTimedOut( - sink chan *abi.BridgeMovedFundsSweepTimedOut, +func (b *Bridge) watchMovingFundsCommitmentSubmitted( + sink chan *abi.BridgeMovingFundsCommitmentSubmitted, walletPubKeyHashFilter [][20]byte, ) event.Subscription { subscribeFn := func(ctx context.Context) (event.Subscription, error) { - return b.contract.WatchMovedFundsSweepTimedOut( + return b.contract.WatchMovingFundsCommitmentSubmitted( &bind.WatchOpts{Context: ctx}, sink, walletPubKeyHashFilter, @@ -9044,7 +10884,7 @@ func (b *Bridge) watchMovedFundsSweepTimedOut( thresholdViolatedFn := func(elapsed time.Duration) { bLogger.Warnf( - "subscription to event MovedFundsSweepTimedOut had to be "+ + "subscription to event MovingFundsCommitmentSubmitted had to be "+ "retried [%s] since the last attempt; please inspect "+ "host chain connectivity", elapsed, @@ -9053,7 +10893,7 @@ func (b *Bridge) watchMovedFundsSweepTimedOut( subscriptionFailedFn := func(err error) { bLogger.Errorf( - "subscription to event MovedFundsSweepTimedOut failed "+ + "subscription to event MovingFundsCommitmentSubmitted failed "+ "with error: [%v]; resubscription attempt will be "+ "performed", err, @@ -9069,12 +10909,12 @@ func (b *Bridge) watchMovedFundsSweepTimedOut( ) } -func (b *Bridge) PastMovedFundsSweepTimedOutEvents( +func (b *Bridge) PastMovingFundsCommitmentSubmittedEvents( startBlock uint64, endBlock *uint64, walletPubKeyHashFilter [][20]byte, -) ([]*abi.BridgeMovedFundsSweepTimedOut, error) { - iterator, err := b.contract.FilterMovedFundsSweepTimedOut( +) ([]*abi.BridgeMovingFundsCommitmentSubmitted, error) { + iterator, err := b.contract.FilterMovingFundsCommitmentSubmitted( &bind.FilterOpts{ Start: startBlock, End: endBlock, @@ -9083,12 +10923,12 @@ func (b *Bridge) PastMovedFundsSweepTimedOutEvents( ) if err != nil { return nil, fmt.Errorf( - "error retrieving past MovedFundsSweepTimedOut events: [%v]", + "error retrieving past MovingFundsCommitmentSubmitted events: [%v]", err, ) } - events := make([]*abi.BridgeMovedFundsSweepTimedOut, 0) + events := make([]*abi.BridgeMovingFundsCommitmentSubmitted, 0) for iterator.Next() { event := iterator.Event @@ -9098,10 +10938,10 @@ func (b *Bridge) PastMovedFundsSweepTimedOutEvents( return events, nil } -func (b *Bridge) MovedFundsSweptEvent( +func (b *Bridge) MovingFundsCompletedEvent( opts *ethereum.SubscribeOpts, walletPubKeyHashFilter [][20]byte, -) *BMovedFundsSweptSubscription { +) *BMovingFundsCompletedSubscription { if opts == nil { opts = new(ethereum.SubscribeOpts) } @@ -9112,29 +10952,29 @@ func (b *Bridge) MovedFundsSweptEvent( opts.PastBlocks = chainutil.DefaultSubscribeOptsPastBlocks } - return &BMovedFundsSweptSubscription{ + return &BMovingFundsCompletedSubscription{ b, opts, walletPubKeyHashFilter, } } -type BMovedFundsSweptSubscription struct { +type BMovingFundsCompletedSubscription struct { contract *Bridge opts *ethereum.SubscribeOpts walletPubKeyHashFilter [][20]byte } -type bridgeMovedFundsSweptFunc func( +type bridgeMovingFundsCompletedFunc func( WalletPubKeyHash [20]byte, - SweepTxHash [32]byte, + MovingFundsTxHash [32]byte, blockNumber uint64, ) -func (mfss *BMovedFundsSweptSubscription) OnEvent( - handler bridgeMovedFundsSweptFunc, +func (mfcs *BMovingFundsCompletedSubscription) OnEvent( + handler bridgeMovingFundsCompletedFunc, ) subscription.EventSubscription { - eventChan := make(chan *abi.BridgeMovedFundsSwept) + eventChan := make(chan *abi.BridgeMovingFundsCompleted) ctx, cancelCtx := context.WithCancel(context.Background()) go func() { @@ -9145,50 +10985,50 @@ func (mfss *BMovedFundsSweptSubscription) OnEvent( case event := <-eventChan: handler( event.WalletPubKeyHash, - event.SweepTxHash, + event.MovingFundsTxHash, event.Raw.BlockNumber, ) } } }() - sub := mfss.Pipe(eventChan) + sub := mfcs.Pipe(eventChan) return subscription.NewEventSubscription(func() { sub.Unsubscribe() cancelCtx() }) } -func (mfss *BMovedFundsSweptSubscription) Pipe( - sink chan *abi.BridgeMovedFundsSwept, +func (mfcs *BMovingFundsCompletedSubscription) Pipe( + sink chan *abi.BridgeMovingFundsCompleted, ) subscription.EventSubscription { ctx, cancelCtx := context.WithCancel(context.Background()) go func() { - ticker := time.NewTicker(mfss.opts.Tick) + ticker := time.NewTicker(mfcs.opts.Tick) defer ticker.Stop() for { select { case <-ctx.Done(): return case <-ticker.C: - lastBlock, err := mfss.contract.blockCounter.CurrentBlock() + lastBlock, err := mfcs.contract.blockCounter.CurrentBlock() if err != nil { bLogger.Errorf( "subscription failed to pull events: [%v]", err, ) } - fromBlock := lastBlock - mfss.opts.PastBlocks + fromBlock := lastBlock - mfcs.opts.PastBlocks bLogger.Infof( - "subscription monitoring fetching past MovedFundsSwept events "+ + "subscription monitoring fetching past MovingFundsCompleted events "+ "starting from block [%v]", fromBlock, ) - events, err := mfss.contract.PastMovedFundsSweptEvents( + events, err := mfcs.contract.PastMovingFundsCompletedEvents( fromBlock, nil, - mfss.walletPubKeyHashFilter, + mfcs.walletPubKeyHashFilter, ) if err != nil { bLogger.Errorf( @@ -9198,7 +11038,7 @@ func (mfss *BMovedFundsSweptSubscription) Pipe( continue } bLogger.Infof( - "subscription monitoring fetched [%v] past MovedFundsSwept events", + "subscription monitoring fetched [%v] past MovingFundsCompleted events", len(events), ) @@ -9209,9 +11049,9 @@ func (mfss *BMovedFundsSweptSubscription) Pipe( } }() - sub := mfss.contract.watchMovedFundsSwept( + sub := mfcs.contract.watchMovingFundsCompleted( sink, - mfss.walletPubKeyHashFilter, + mfcs.walletPubKeyHashFilter, ) return subscription.NewEventSubscription(func() { @@ -9220,12 +11060,12 @@ func (mfss *BMovedFundsSweptSubscription) Pipe( }) } -func (b *Bridge) watchMovedFundsSwept( - sink chan *abi.BridgeMovedFundsSwept, +func (b *Bridge) watchMovingFundsCompleted( + sink chan *abi.BridgeMovingFundsCompleted, walletPubKeyHashFilter [][20]byte, ) event.Subscription { subscribeFn := func(ctx context.Context) (event.Subscription, error) { - return b.contract.WatchMovedFundsSwept( + return b.contract.WatchMovingFundsCompleted( &bind.WatchOpts{Context: ctx}, sink, walletPubKeyHashFilter, @@ -9234,7 +11074,7 @@ func (b *Bridge) watchMovedFundsSwept( thresholdViolatedFn := func(elapsed time.Duration) { bLogger.Warnf( - "subscription to event MovedFundsSwept had to be "+ + "subscription to event MovingFundsCompleted had to be "+ "retried [%s] since the last attempt; please inspect "+ "host chain connectivity", elapsed, @@ -9243,7 +11083,7 @@ func (b *Bridge) watchMovedFundsSwept( subscriptionFailedFn := func(err error) { bLogger.Errorf( - "subscription to event MovedFundsSwept failed "+ + "subscription to event MovingFundsCompleted failed "+ "with error: [%v]; resubscription attempt will be "+ "performed", err, @@ -9259,12 +11099,12 @@ func (b *Bridge) watchMovedFundsSwept( ) } -func (b *Bridge) PastMovedFundsSweptEvents( +func (b *Bridge) PastMovingFundsCompletedEvents( startBlock uint64, endBlock *uint64, walletPubKeyHashFilter [][20]byte, -) ([]*abi.BridgeMovedFundsSwept, error) { - iterator, err := b.contract.FilterMovedFundsSwept( +) ([]*abi.BridgeMovingFundsCompleted, error) { + iterator, err := b.contract.FilterMovingFundsCompleted( &bind.FilterOpts{ Start: startBlock, End: endBlock, @@ -9273,12 +11113,12 @@ func (b *Bridge) PastMovedFundsSweptEvents( ) if err != nil { return nil, fmt.Errorf( - "error retrieving past MovedFundsSwept events: [%v]", + "error retrieving past MovingFundsCompleted events: [%v]", err, ) } - events := make([]*abi.BridgeMovedFundsSwept, 0) + events := make([]*abi.BridgeMovingFundsCompleted, 0) for iterator.Next() { event := iterator.Event @@ -9288,10 +11128,9 @@ func (b *Bridge) PastMovedFundsSweptEvents( return events, nil } -func (b *Bridge) MovingFundsBelowDustReportedEvent( +func (b *Bridge) MovingFundsParametersUpdatedEvent( opts *ethereum.SubscribeOpts, - walletPubKeyHashFilter [][20]byte, -) *BMovingFundsBelowDustReportedSubscription { +) *BMovingFundsParametersUpdatedSubscription { if opts == nil { opts = new(ethereum.SubscribeOpts) } @@ -9302,28 +11141,36 @@ func (b *Bridge) MovingFundsBelowDustReportedEvent( opts.PastBlocks = chainutil.DefaultSubscribeOptsPastBlocks } - return &BMovingFundsBelowDustReportedSubscription{ + return &BMovingFundsParametersUpdatedSubscription{ b, opts, - walletPubKeyHashFilter, } } -type BMovingFundsBelowDustReportedSubscription struct { - contract *Bridge - opts *ethereum.SubscribeOpts - walletPubKeyHashFilter [][20]byte +type BMovingFundsParametersUpdatedSubscription struct { + contract *Bridge + opts *ethereum.SubscribeOpts } -type bridgeMovingFundsBelowDustReportedFunc func( - WalletPubKeyHash [20]byte, +type bridgeMovingFundsParametersUpdatedFunc func( + MovingFundsTxMaxTotalFee uint64, + MovingFundsDustThreshold uint64, + MovingFundsTimeoutResetDelay uint32, + MovingFundsTimeout uint32, + MovingFundsTimeoutSlashingAmount *big.Int, + MovingFundsTimeoutNotifierRewardMultiplier uint32, + MovingFundsCommitmentGasOffset uint16, + MovedFundsSweepTxMaxTotalFee uint64, + MovedFundsSweepTimeout uint32, + MovedFundsSweepTimeoutSlashingAmount *big.Int, + MovedFundsSweepTimeoutNotifierRewardMultiplier uint32, blockNumber uint64, ) - -func (mfbdrs *BMovingFundsBelowDustReportedSubscription) OnEvent( - handler bridgeMovingFundsBelowDustReportedFunc, + +func (mfpus *BMovingFundsParametersUpdatedSubscription) OnEvent( + handler bridgeMovingFundsParametersUpdatedFunc, ) subscription.EventSubscription { - eventChan := make(chan *abi.BridgeMovingFundsBelowDustReported) + eventChan := make(chan *abi.BridgeMovingFundsParametersUpdated) ctx, cancelCtx := context.WithCancel(context.Background()) go func() { @@ -9333,50 +11180,59 @@ func (mfbdrs *BMovingFundsBelowDustReportedSubscription) OnEvent( return case event := <-eventChan: handler( - event.WalletPubKeyHash, + event.MovingFundsTxMaxTotalFee, + event.MovingFundsDustThreshold, + event.MovingFundsTimeoutResetDelay, + event.MovingFundsTimeout, + event.MovingFundsTimeoutSlashingAmount, + event.MovingFundsTimeoutNotifierRewardMultiplier, + event.MovingFundsCommitmentGasOffset, + event.MovedFundsSweepTxMaxTotalFee, + event.MovedFundsSweepTimeout, + event.MovedFundsSweepTimeoutSlashingAmount, + event.MovedFundsSweepTimeoutNotifierRewardMultiplier, event.Raw.BlockNumber, ) } } }() - sub := mfbdrs.Pipe(eventChan) + sub := mfpus.Pipe(eventChan) return subscription.NewEventSubscription(func() { sub.Unsubscribe() cancelCtx() }) } -func (mfbdrs *BMovingFundsBelowDustReportedSubscription) Pipe( - sink chan *abi.BridgeMovingFundsBelowDustReported, +func (mfpus *BMovingFundsParametersUpdatedSubscription) Pipe( + sink chan *abi.BridgeMovingFundsParametersUpdated, ) subscription.EventSubscription { ctx, cancelCtx := context.WithCancel(context.Background()) go func() { - ticker := time.NewTicker(mfbdrs.opts.Tick) + ticker := time.NewTicker(mfpus.opts.Tick) defer ticker.Stop() for { select { case <-ctx.Done(): return case <-ticker.C: - lastBlock, err := mfbdrs.contract.blockCounter.CurrentBlock() + lastBlock, err := mfpus.contract.blockCounter.CurrentBlock() if err != nil { bLogger.Errorf( "subscription failed to pull events: [%v]", err, ) } - fromBlock := lastBlock - mfbdrs.opts.PastBlocks + fromBlock := lastBlock - mfpus.opts.PastBlocks bLogger.Infof( - "subscription monitoring fetching past MovingFundsBelowDustReported events "+ + "subscription monitoring fetching past MovingFundsParametersUpdated events "+ "starting from block [%v]", fromBlock, ) - events, err := mfbdrs.contract.PastMovingFundsBelowDustReportedEvents( + events, err := mfpus.contract.PastMovingFundsParametersUpdatedEvents( fromBlock, nil, - mfbdrs.walletPubKeyHashFilter, ) if err != nil { bLogger.Errorf( @@ -9386,7 +11242,7 @@ func (mfbdrs *BMovingFundsBelowDustReportedSubscription) Pipe( continue } bLogger.Infof( - "subscription monitoring fetched [%v] past MovingFundsBelowDustReported events", + "subscription monitoring fetched [%v] past MovingFundsParametersUpdated events", len(events), ) @@ -9397,9 +11253,8 @@ func (mfbdrs *BMovingFundsBelowDustReportedSubscription) Pipe( } }() - sub := mfbdrs.contract.watchMovingFundsBelowDustReported( + sub := mfpus.contract.watchMovingFundsParametersUpdated( sink, - mfbdrs.walletPubKeyHashFilter, ) return subscription.NewEventSubscription(func() { @@ -9408,21 +11263,19 @@ func (mfbdrs *BMovingFundsBelowDustReportedSubscription) Pipe( }) } -func (b *Bridge) watchMovingFundsBelowDustReported( - sink chan *abi.BridgeMovingFundsBelowDustReported, - walletPubKeyHashFilter [][20]byte, +func (b *Bridge) watchMovingFundsParametersUpdated( + sink chan *abi.BridgeMovingFundsParametersUpdated, ) event.Subscription { subscribeFn := func(ctx context.Context) (event.Subscription, error) { - return b.contract.WatchMovingFundsBelowDustReported( + return b.contract.WatchMovingFundsParametersUpdated( &bind.WatchOpts{Context: ctx}, sink, - walletPubKeyHashFilter, ) } thresholdViolatedFn := func(elapsed time.Duration) { bLogger.Warnf( - "subscription to event MovingFundsBelowDustReported had to be "+ + "subscription to event MovingFundsParametersUpdated had to be "+ "retried [%s] since the last attempt; please inspect "+ "host chain connectivity", elapsed, @@ -9431,7 +11284,7 @@ func (b *Bridge) watchMovingFundsBelowDustReported( subscriptionFailedFn := func(err error) { bLogger.Errorf( - "subscription to event MovingFundsBelowDustReported failed "+ + "subscription to event MovingFundsParametersUpdated failed "+ "with error: [%v]; resubscription attempt will be "+ "performed", err, @@ -9447,26 +11300,24 @@ func (b *Bridge) watchMovingFundsBelowDustReported( ) } -func (b *Bridge) PastMovingFundsBelowDustReportedEvents( +func (b *Bridge) PastMovingFundsParametersUpdatedEvents( startBlock uint64, endBlock *uint64, - walletPubKeyHashFilter [][20]byte, -) ([]*abi.BridgeMovingFundsBelowDustReported, error) { - iterator, err := b.contract.FilterMovingFundsBelowDustReported( +) ([]*abi.BridgeMovingFundsParametersUpdated, error) { + iterator, err := b.contract.FilterMovingFundsParametersUpdated( &bind.FilterOpts{ Start: startBlock, End: endBlock, }, - walletPubKeyHashFilter, ) if err != nil { return nil, fmt.Errorf( - "error retrieving past MovingFundsBelowDustReported events: [%v]", + "error retrieving past MovingFundsParametersUpdated events: [%v]", err, ) } - events := make([]*abi.BridgeMovingFundsBelowDustReported, 0) + events := make([]*abi.BridgeMovingFundsParametersUpdated, 0) for iterator.Next() { event := iterator.Event @@ -9476,10 +11327,10 @@ func (b *Bridge) PastMovingFundsBelowDustReportedEvents( return events, nil } -func (b *Bridge) MovingFundsCommitmentSubmittedEvent( +func (b *Bridge) MovingFundsTimedOutEvent( opts *ethereum.SubscribeOpts, walletPubKeyHashFilter [][20]byte, -) *BMovingFundsCommitmentSubmittedSubscription { +) *BMovingFundsTimedOutSubscription { if opts == nil { opts = new(ethereum.SubscribeOpts) } @@ -9490,30 +11341,28 @@ func (b *Bridge) MovingFundsCommitmentSubmittedEvent( opts.PastBlocks = chainutil.DefaultSubscribeOptsPastBlocks } - return &BMovingFundsCommitmentSubmittedSubscription{ + return &BMovingFundsTimedOutSubscription{ b, opts, walletPubKeyHashFilter, } } -type BMovingFundsCommitmentSubmittedSubscription struct { +type BMovingFundsTimedOutSubscription struct { contract *Bridge opts *ethereum.SubscribeOpts walletPubKeyHashFilter [][20]byte } -type bridgeMovingFundsCommitmentSubmittedFunc func( +type bridgeMovingFundsTimedOutFunc func( WalletPubKeyHash [20]byte, - TargetWallets [][20]byte, - Submitter common.Address, blockNumber uint64, ) -func (mfcss *BMovingFundsCommitmentSubmittedSubscription) OnEvent( - handler bridgeMovingFundsCommitmentSubmittedFunc, +func (mftos *BMovingFundsTimedOutSubscription) OnEvent( + handler bridgeMovingFundsTimedOutFunc, ) subscription.EventSubscription { - eventChan := make(chan *abi.BridgeMovingFundsCommitmentSubmitted) + eventChan := make(chan *abi.BridgeMovingFundsTimedOut) ctx, cancelCtx := context.WithCancel(context.Background()) go func() { @@ -9524,51 +11373,49 @@ func (mfcss *BMovingFundsCommitmentSubmittedSubscription) OnEvent( case event := <-eventChan: handler( event.WalletPubKeyHash, - event.TargetWallets, - event.Submitter, event.Raw.BlockNumber, ) } } }() - sub := mfcss.Pipe(eventChan) + sub := mftos.Pipe(eventChan) return subscription.NewEventSubscription(func() { sub.Unsubscribe() cancelCtx() }) } -func (mfcss *BMovingFundsCommitmentSubmittedSubscription) Pipe( - sink chan *abi.BridgeMovingFundsCommitmentSubmitted, +func (mftos *BMovingFundsTimedOutSubscription) Pipe( + sink chan *abi.BridgeMovingFundsTimedOut, ) subscription.EventSubscription { ctx, cancelCtx := context.WithCancel(context.Background()) go func() { - ticker := time.NewTicker(mfcss.opts.Tick) + ticker := time.NewTicker(mftos.opts.Tick) defer ticker.Stop() for { select { case <-ctx.Done(): return case <-ticker.C: - lastBlock, err := mfcss.contract.blockCounter.CurrentBlock() + lastBlock, err := mftos.contract.blockCounter.CurrentBlock() if err != nil { bLogger.Errorf( "subscription failed to pull events: [%v]", err, ) } - fromBlock := lastBlock - mfcss.opts.PastBlocks + fromBlock := lastBlock - mftos.opts.PastBlocks bLogger.Infof( - "subscription monitoring fetching past MovingFundsCommitmentSubmitted events "+ + "subscription monitoring fetching past MovingFundsTimedOut events "+ "starting from block [%v]", fromBlock, ) - events, err := mfcss.contract.PastMovingFundsCommitmentSubmittedEvents( + events, err := mftos.contract.PastMovingFundsTimedOutEvents( fromBlock, nil, - mfcss.walletPubKeyHashFilter, + mftos.walletPubKeyHashFilter, ) if err != nil { bLogger.Errorf( @@ -9578,7 +11425,7 @@ func (mfcss *BMovingFundsCommitmentSubmittedSubscription) Pipe( continue } bLogger.Infof( - "subscription monitoring fetched [%v] past MovingFundsCommitmentSubmitted events", + "subscription monitoring fetched [%v] past MovingFundsTimedOut events", len(events), ) @@ -9589,9 +11436,9 @@ func (mfcss *BMovingFundsCommitmentSubmittedSubscription) Pipe( } }() - sub := mfcss.contract.watchMovingFundsCommitmentSubmitted( + sub := mftos.contract.watchMovingFundsTimedOut( sink, - mfcss.walletPubKeyHashFilter, + mftos.walletPubKeyHashFilter, ) return subscription.NewEventSubscription(func() { @@ -9600,12 +11447,12 @@ func (mfcss *BMovingFundsCommitmentSubmittedSubscription) Pipe( }) } -func (b *Bridge) watchMovingFundsCommitmentSubmitted( - sink chan *abi.BridgeMovingFundsCommitmentSubmitted, +func (b *Bridge) watchMovingFundsTimedOut( + sink chan *abi.BridgeMovingFundsTimedOut, walletPubKeyHashFilter [][20]byte, ) event.Subscription { subscribeFn := func(ctx context.Context) (event.Subscription, error) { - return b.contract.WatchMovingFundsCommitmentSubmitted( + return b.contract.WatchMovingFundsTimedOut( &bind.WatchOpts{Context: ctx}, sink, walletPubKeyHashFilter, @@ -9614,7 +11461,7 @@ func (b *Bridge) watchMovingFundsCommitmentSubmitted( thresholdViolatedFn := func(elapsed time.Duration) { bLogger.Warnf( - "subscription to event MovingFundsCommitmentSubmitted had to be "+ + "subscription to event MovingFundsTimedOut had to be "+ "retried [%s] since the last attempt; please inspect "+ "host chain connectivity", elapsed, @@ -9623,7 +11470,7 @@ func (b *Bridge) watchMovingFundsCommitmentSubmitted( subscriptionFailedFn := func(err error) { bLogger.Errorf( - "subscription to event MovingFundsCommitmentSubmitted failed "+ + "subscription to event MovingFundsTimedOut failed "+ "with error: [%v]; resubscription attempt will be "+ "performed", err, @@ -9639,12 +11486,12 @@ func (b *Bridge) watchMovingFundsCommitmentSubmitted( ) } -func (b *Bridge) PastMovingFundsCommitmentSubmittedEvents( +func (b *Bridge) PastMovingFundsTimedOutEvents( startBlock uint64, endBlock *uint64, walletPubKeyHashFilter [][20]byte, -) ([]*abi.BridgeMovingFundsCommitmentSubmitted, error) { - iterator, err := b.contract.FilterMovingFundsCommitmentSubmitted( +) ([]*abi.BridgeMovingFundsTimedOut, error) { + iterator, err := b.contract.FilterMovingFundsTimedOut( &bind.FilterOpts{ Start: startBlock, End: endBlock, @@ -9653,12 +11500,12 @@ func (b *Bridge) PastMovingFundsCommitmentSubmittedEvents( ) if err != nil { return nil, fmt.Errorf( - "error retrieving past MovingFundsCommitmentSubmitted events: [%v]", + "error retrieving past MovingFundsTimedOut events: [%v]", err, ) } - events := make([]*abi.BridgeMovingFundsCommitmentSubmitted, 0) + events := make([]*abi.BridgeMovingFundsTimedOut, 0) for iterator.Next() { event := iterator.Event @@ -9668,10 +11515,10 @@ func (b *Bridge) PastMovingFundsCommitmentSubmittedEvents( return events, nil } -func (b *Bridge) MovingFundsCompletedEvent( +func (b *Bridge) MovingFundsTimeoutResetEvent( opts *ethereum.SubscribeOpts, walletPubKeyHashFilter [][20]byte, -) *BMovingFundsCompletedSubscription { +) *BMovingFundsTimeoutResetSubscription { if opts == nil { opts = new(ethereum.SubscribeOpts) } @@ -9682,29 +11529,28 @@ func (b *Bridge) MovingFundsCompletedEvent( opts.PastBlocks = chainutil.DefaultSubscribeOptsPastBlocks } - return &BMovingFundsCompletedSubscription{ + return &BMovingFundsTimeoutResetSubscription{ b, opts, walletPubKeyHashFilter, } } -type BMovingFundsCompletedSubscription struct { +type BMovingFundsTimeoutResetSubscription struct { contract *Bridge opts *ethereum.SubscribeOpts walletPubKeyHashFilter [][20]byte } -type bridgeMovingFundsCompletedFunc func( +type bridgeMovingFundsTimeoutResetFunc func( WalletPubKeyHash [20]byte, - MovingFundsTxHash [32]byte, blockNumber uint64, ) -func (mfcs *BMovingFundsCompletedSubscription) OnEvent( - handler bridgeMovingFundsCompletedFunc, +func (mftrs *BMovingFundsTimeoutResetSubscription) OnEvent( + handler bridgeMovingFundsTimeoutResetFunc, ) subscription.EventSubscription { - eventChan := make(chan *abi.BridgeMovingFundsCompleted) + eventChan := make(chan *abi.BridgeMovingFundsTimeoutReset) ctx, cancelCtx := context.WithCancel(context.Background()) go func() { @@ -9715,50 +11561,49 @@ func (mfcs *BMovingFundsCompletedSubscription) OnEvent( case event := <-eventChan: handler( event.WalletPubKeyHash, - event.MovingFundsTxHash, event.Raw.BlockNumber, ) } } }() - sub := mfcs.Pipe(eventChan) + sub := mftrs.Pipe(eventChan) return subscription.NewEventSubscription(func() { sub.Unsubscribe() cancelCtx() }) } -func (mfcs *BMovingFundsCompletedSubscription) Pipe( - sink chan *abi.BridgeMovingFundsCompleted, +func (mftrs *BMovingFundsTimeoutResetSubscription) Pipe( + sink chan *abi.BridgeMovingFundsTimeoutReset, ) subscription.EventSubscription { ctx, cancelCtx := context.WithCancel(context.Background()) go func() { - ticker := time.NewTicker(mfcs.opts.Tick) + ticker := time.NewTicker(mftrs.opts.Tick) defer ticker.Stop() for { select { case <-ctx.Done(): return case <-ticker.C: - lastBlock, err := mfcs.contract.blockCounter.CurrentBlock() + lastBlock, err := mftrs.contract.blockCounter.CurrentBlock() if err != nil { bLogger.Errorf( "subscription failed to pull events: [%v]", err, ) } - fromBlock := lastBlock - mfcs.opts.PastBlocks + fromBlock := lastBlock - mftrs.opts.PastBlocks bLogger.Infof( - "subscription monitoring fetching past MovingFundsCompleted events "+ + "subscription monitoring fetching past MovingFundsTimeoutReset events "+ "starting from block [%v]", fromBlock, ) - events, err := mfcs.contract.PastMovingFundsCompletedEvents( + events, err := mftrs.contract.PastMovingFundsTimeoutResetEvents( fromBlock, nil, - mfcs.walletPubKeyHashFilter, + mftrs.walletPubKeyHashFilter, ) if err != nil { bLogger.Errorf( @@ -9768,7 +11613,7 @@ func (mfcs *BMovingFundsCompletedSubscription) Pipe( continue } bLogger.Infof( - "subscription monitoring fetched [%v] past MovingFundsCompleted events", + "subscription monitoring fetched [%v] past MovingFundsTimeoutReset events", len(events), ) @@ -9779,9 +11624,9 @@ func (mfcs *BMovingFundsCompletedSubscription) Pipe( } }() - sub := mfcs.contract.watchMovingFundsCompleted( + sub := mftrs.contract.watchMovingFundsTimeoutReset( sink, - mfcs.walletPubKeyHashFilter, + mftrs.walletPubKeyHashFilter, ) return subscription.NewEventSubscription(func() { @@ -9790,12 +11635,12 @@ func (mfcs *BMovingFundsCompletedSubscription) Pipe( }) } -func (b *Bridge) watchMovingFundsCompleted( - sink chan *abi.BridgeMovingFundsCompleted, +func (b *Bridge) watchMovingFundsTimeoutReset( + sink chan *abi.BridgeMovingFundsTimeoutReset, walletPubKeyHashFilter [][20]byte, ) event.Subscription { subscribeFn := func(ctx context.Context) (event.Subscription, error) { - return b.contract.WatchMovingFundsCompleted( + return b.contract.WatchMovingFundsTimeoutReset( &bind.WatchOpts{Context: ctx}, sink, walletPubKeyHashFilter, @@ -9804,7 +11649,7 @@ func (b *Bridge) watchMovingFundsCompleted( thresholdViolatedFn := func(elapsed time.Duration) { bLogger.Warnf( - "subscription to event MovingFundsCompleted had to be "+ + "subscription to event MovingFundsTimeoutReset had to be "+ "retried [%s] since the last attempt; please inspect "+ "host chain connectivity", elapsed, @@ -9813,7 +11658,7 @@ func (b *Bridge) watchMovingFundsCompleted( subscriptionFailedFn := func(err error) { bLogger.Errorf( - "subscription to event MovingFundsCompleted failed "+ + "subscription to event MovingFundsTimeoutReset failed "+ "with error: [%v]; resubscription attempt will be "+ "performed", err, @@ -9829,12 +11674,12 @@ func (b *Bridge) watchMovingFundsCompleted( ) } -func (b *Bridge) PastMovingFundsCompletedEvents( +func (b *Bridge) PastMovingFundsTimeoutResetEvents( startBlock uint64, endBlock *uint64, walletPubKeyHashFilter [][20]byte, -) ([]*abi.BridgeMovingFundsCompleted, error) { - iterator, err := b.contract.FilterMovingFundsCompleted( +) ([]*abi.BridgeMovingFundsTimeoutReset, error) { + iterator, err := b.contract.FilterMovingFundsTimeoutReset( &bind.FilterOpts{ Start: startBlock, End: endBlock, @@ -9843,12 +11688,12 @@ func (b *Bridge) PastMovingFundsCompletedEvents( ) if err != nil { return nil, fmt.Errorf( - "error retrieving past MovingFundsCompleted events: [%v]", + "error retrieving past MovingFundsTimeoutReset events: [%v]", err, ) } - events := make([]*abi.BridgeMovingFundsCompleted, 0) + events := make([]*abi.BridgeMovingFundsTimeoutReset, 0) for iterator.Next() { event := iterator.Event @@ -9858,9 +11703,12 @@ func (b *Bridge) PastMovingFundsCompletedEvents( return events, nil } -func (b *Bridge) MovingFundsParametersUpdatedEvent( +func (b *Bridge) NewFrostWalletRegisteredEvent( opts *ethereum.SubscribeOpts, -) *BMovingFundsParametersUpdatedSubscription { + walletIDFilter [][32]byte, + walletPubKeyHashFilter [][20]byte, + xOnlyOutputKeyFilter [][32]byte, +) *BNewFrostWalletRegisteredSubscription { if opts == nil { opts = new(ethereum.SubscribeOpts) } @@ -9871,36 +11719,34 @@ func (b *Bridge) MovingFundsParametersUpdatedEvent( opts.PastBlocks = chainutil.DefaultSubscribeOptsPastBlocks } - return &BMovingFundsParametersUpdatedSubscription{ + return &BNewFrostWalletRegisteredSubscription{ b, opts, + walletIDFilter, + walletPubKeyHashFilter, + xOnlyOutputKeyFilter, } } -type BMovingFundsParametersUpdatedSubscription struct { - contract *Bridge - opts *ethereum.SubscribeOpts +type BNewFrostWalletRegisteredSubscription struct { + contract *Bridge + opts *ethereum.SubscribeOpts + walletIDFilter [][32]byte + walletPubKeyHashFilter [][20]byte + xOnlyOutputKeyFilter [][32]byte } -type bridgeMovingFundsParametersUpdatedFunc func( - MovingFundsTxMaxTotalFee uint64, - MovingFundsDustThreshold uint64, - MovingFundsTimeoutResetDelay uint32, - MovingFundsTimeout uint32, - MovingFundsTimeoutSlashingAmount *big.Int, - MovingFundsTimeoutNotifierRewardMultiplier uint32, - MovingFundsCommitmentGasOffset uint16, - MovedFundsSweepTxMaxTotalFee uint64, - MovedFundsSweepTimeout uint32, - MovedFundsSweepTimeoutSlashingAmount *big.Int, - MovedFundsSweepTimeoutNotifierRewardMultiplier uint32, +type bridgeNewFrostWalletRegisteredFunc func( + WalletID [32]byte, + WalletPubKeyHash [20]byte, + XOnlyOutputKey [32]byte, blockNumber uint64, ) -func (mfpus *BMovingFundsParametersUpdatedSubscription) OnEvent( - handler bridgeMovingFundsParametersUpdatedFunc, +func (nfwrs *BNewFrostWalletRegisteredSubscription) OnEvent( + handler bridgeNewFrostWalletRegisteredFunc, ) subscription.EventSubscription { - eventChan := make(chan *abi.BridgeMovingFundsParametersUpdated) + eventChan := make(chan *abi.BridgeNewFrostWalletRegistered) ctx, cancelCtx := context.WithCancel(context.Background()) go func() { @@ -9910,59 +11756,54 @@ func (mfpus *BMovingFundsParametersUpdatedSubscription) OnEvent( return case event := <-eventChan: handler( - event.MovingFundsTxMaxTotalFee, - event.MovingFundsDustThreshold, - event.MovingFundsTimeoutResetDelay, - event.MovingFundsTimeout, - event.MovingFundsTimeoutSlashingAmount, - event.MovingFundsTimeoutNotifierRewardMultiplier, - event.MovingFundsCommitmentGasOffset, - event.MovedFundsSweepTxMaxTotalFee, - event.MovedFundsSweepTimeout, - event.MovedFundsSweepTimeoutSlashingAmount, - event.MovedFundsSweepTimeoutNotifierRewardMultiplier, + event.WalletID, + event.WalletPubKeyHash, + event.XOnlyOutputKey, event.Raw.BlockNumber, ) } } }() - sub := mfpus.Pipe(eventChan) + sub := nfwrs.Pipe(eventChan) return subscription.NewEventSubscription(func() { sub.Unsubscribe() cancelCtx() }) } -func (mfpus *BMovingFundsParametersUpdatedSubscription) Pipe( - sink chan *abi.BridgeMovingFundsParametersUpdated, +func (nfwrs *BNewFrostWalletRegisteredSubscription) Pipe( + sink chan *abi.BridgeNewFrostWalletRegistered, ) subscription.EventSubscription { ctx, cancelCtx := context.WithCancel(context.Background()) go func() { - ticker := time.NewTicker(mfpus.opts.Tick) + ticker := time.NewTicker(nfwrs.opts.Tick) defer ticker.Stop() for { select { case <-ctx.Done(): return case <-ticker.C: - lastBlock, err := mfpus.contract.blockCounter.CurrentBlock() + lastBlock, err := nfwrs.contract.blockCounter.CurrentBlock() if err != nil { bLogger.Errorf( "subscription failed to pull events: [%v]", err, ) } - fromBlock := lastBlock - mfpus.opts.PastBlocks + fromBlock := lastBlock - nfwrs.opts.PastBlocks bLogger.Infof( - "subscription monitoring fetching past MovingFundsParametersUpdated events "+ + "subscription monitoring fetching past NewFrostWalletRegistered events "+ "starting from block [%v]", fromBlock, ) - events, err := mfpus.contract.PastMovingFundsParametersUpdatedEvents( + events, err := nfwrs.contract.PastNewFrostWalletRegisteredEvents( fromBlock, nil, + nfwrs.walletIDFilter, + nfwrs.walletPubKeyHashFilter, + nfwrs.xOnlyOutputKeyFilter, ) if err != nil { bLogger.Errorf( @@ -9972,7 +11813,7 @@ func (mfpus *BMovingFundsParametersUpdatedSubscription) Pipe( continue } bLogger.Infof( - "subscription monitoring fetched [%v] past MovingFundsParametersUpdated events", + "subscription monitoring fetched [%v] past NewFrostWalletRegistered events", len(events), ) @@ -9983,8 +11824,11 @@ func (mfpus *BMovingFundsParametersUpdatedSubscription) Pipe( } }() - sub := mfpus.contract.watchMovingFundsParametersUpdated( + sub := nfwrs.contract.watchNewFrostWalletRegistered( sink, + nfwrs.walletIDFilter, + nfwrs.walletPubKeyHashFilter, + nfwrs.xOnlyOutputKeyFilter, ) return subscription.NewEventSubscription(func() { @@ -9993,19 +11837,25 @@ func (mfpus *BMovingFundsParametersUpdatedSubscription) Pipe( }) } -func (b *Bridge) watchMovingFundsParametersUpdated( - sink chan *abi.BridgeMovingFundsParametersUpdated, +func (b *Bridge) watchNewFrostWalletRegistered( + sink chan *abi.BridgeNewFrostWalletRegistered, + walletIDFilter [][32]byte, + walletPubKeyHashFilter [][20]byte, + xOnlyOutputKeyFilter [][32]byte, ) event.Subscription { subscribeFn := func(ctx context.Context) (event.Subscription, error) { - return b.contract.WatchMovingFundsParametersUpdated( + return b.contract.WatchNewFrostWalletRegistered( &bind.WatchOpts{Context: ctx}, sink, + walletIDFilter, + walletPubKeyHashFilter, + xOnlyOutputKeyFilter, ) } thresholdViolatedFn := func(elapsed time.Duration) { bLogger.Warnf( - "subscription to event MovingFundsParametersUpdated had to be "+ + "subscription to event NewFrostWalletRegistered had to be "+ "retried [%s] since the last attempt; please inspect "+ "host chain connectivity", elapsed, @@ -10014,7 +11864,7 @@ func (b *Bridge) watchMovingFundsParametersUpdated( subscriptionFailedFn := func(err error) { bLogger.Errorf( - "subscription to event MovingFundsParametersUpdated failed "+ + "subscription to event NewFrostWalletRegistered failed "+ "with error: [%v]; resubscription attempt will be "+ "performed", err, @@ -10030,24 +11880,30 @@ func (b *Bridge) watchMovingFundsParametersUpdated( ) } -func (b *Bridge) PastMovingFundsParametersUpdatedEvents( +func (b *Bridge) PastNewFrostWalletRegisteredEvents( startBlock uint64, - endBlock *uint64, -) ([]*abi.BridgeMovingFundsParametersUpdated, error) { - iterator, err := b.contract.FilterMovingFundsParametersUpdated( + endBlock *uint64, + walletIDFilter [][32]byte, + walletPubKeyHashFilter [][20]byte, + xOnlyOutputKeyFilter [][32]byte, +) ([]*abi.BridgeNewFrostWalletRegistered, error) { + iterator, err := b.contract.FilterNewFrostWalletRegistered( &bind.FilterOpts{ Start: startBlock, End: endBlock, }, + walletIDFilter, + walletPubKeyHashFilter, + xOnlyOutputKeyFilter, ) if err != nil { return nil, fmt.Errorf( - "error retrieving past MovingFundsParametersUpdated events: [%v]", + "error retrieving past NewFrostWalletRegistered events: [%v]", err, ) } - events := make([]*abi.BridgeMovingFundsParametersUpdated, 0) + events := make([]*abi.BridgeNewFrostWalletRegistered, 0) for iterator.Next() { event := iterator.Event @@ -10057,10 +11913,11 @@ func (b *Bridge) PastMovingFundsParametersUpdatedEvents( return events, nil } -func (b *Bridge) MovingFundsTimedOutEvent( +func (b *Bridge) NewWalletRegisteredEvent( opts *ethereum.SubscribeOpts, + ecdsaWalletIDFilter [][32]byte, walletPubKeyHashFilter [][20]byte, -) *BMovingFundsTimedOutSubscription { +) *BNewWalletRegisteredSubscription { if opts == nil { opts = new(ethereum.SubscribeOpts) } @@ -10071,28 +11928,31 @@ func (b *Bridge) MovingFundsTimedOutEvent( opts.PastBlocks = chainutil.DefaultSubscribeOptsPastBlocks } - return &BMovingFundsTimedOutSubscription{ + return &BNewWalletRegisteredSubscription{ b, opts, + ecdsaWalletIDFilter, walletPubKeyHashFilter, } } -type BMovingFundsTimedOutSubscription struct { +type BNewWalletRegisteredSubscription struct { contract *Bridge opts *ethereum.SubscribeOpts + ecdsaWalletIDFilter [][32]byte walletPubKeyHashFilter [][20]byte } -type bridgeMovingFundsTimedOutFunc func( +type bridgeNewWalletRegisteredFunc func( + EcdsaWalletID [32]byte, WalletPubKeyHash [20]byte, blockNumber uint64, ) -func (mftos *BMovingFundsTimedOutSubscription) OnEvent( - handler bridgeMovingFundsTimedOutFunc, +func (nwrs *BNewWalletRegisteredSubscription) OnEvent( + handler bridgeNewWalletRegisteredFunc, ) subscription.EventSubscription { - eventChan := make(chan *abi.BridgeMovingFundsTimedOut) + eventChan := make(chan *abi.BridgeNewWalletRegistered) ctx, cancelCtx := context.WithCancel(context.Background()) go func() { @@ -10102,6 +11962,7 @@ func (mftos *BMovingFundsTimedOutSubscription) OnEvent( return case event := <-eventChan: handler( + event.EcdsaWalletID, event.WalletPubKeyHash, event.Raw.BlockNumber, ) @@ -10109,43 +11970,44 @@ func (mftos *BMovingFundsTimedOutSubscription) OnEvent( } }() - sub := mftos.Pipe(eventChan) + sub := nwrs.Pipe(eventChan) return subscription.NewEventSubscription(func() { sub.Unsubscribe() cancelCtx() }) } -func (mftos *BMovingFundsTimedOutSubscription) Pipe( - sink chan *abi.BridgeMovingFundsTimedOut, +func (nwrs *BNewWalletRegisteredSubscription) Pipe( + sink chan *abi.BridgeNewWalletRegistered, ) subscription.EventSubscription { ctx, cancelCtx := context.WithCancel(context.Background()) go func() { - ticker := time.NewTicker(mftos.opts.Tick) + ticker := time.NewTicker(nwrs.opts.Tick) defer ticker.Stop() for { select { case <-ctx.Done(): return case <-ticker.C: - lastBlock, err := mftos.contract.blockCounter.CurrentBlock() + lastBlock, err := nwrs.contract.blockCounter.CurrentBlock() if err != nil { bLogger.Errorf( "subscription failed to pull events: [%v]", err, ) } - fromBlock := lastBlock - mftos.opts.PastBlocks + fromBlock := lastBlock - nwrs.opts.PastBlocks bLogger.Infof( - "subscription monitoring fetching past MovingFundsTimedOut events "+ + "subscription monitoring fetching past NewWalletRegistered events "+ "starting from block [%v]", fromBlock, ) - events, err := mftos.contract.PastMovingFundsTimedOutEvents( + events, err := nwrs.contract.PastNewWalletRegisteredEvents( fromBlock, nil, - mftos.walletPubKeyHashFilter, + nwrs.ecdsaWalletIDFilter, + nwrs.walletPubKeyHashFilter, ) if err != nil { bLogger.Errorf( @@ -10155,7 +12017,7 @@ func (mftos *BMovingFundsTimedOutSubscription) Pipe( continue } bLogger.Infof( - "subscription monitoring fetched [%v] past MovingFundsTimedOut events", + "subscription monitoring fetched [%v] past NewWalletRegistered events", len(events), ) @@ -10166,9 +12028,10 @@ func (mftos *BMovingFundsTimedOutSubscription) Pipe( } }() - sub := mftos.contract.watchMovingFundsTimedOut( + sub := nwrs.contract.watchNewWalletRegistered( sink, - mftos.walletPubKeyHashFilter, + nwrs.ecdsaWalletIDFilter, + nwrs.walletPubKeyHashFilter, ) return subscription.NewEventSubscription(func() { @@ -10177,21 +12040,23 @@ func (mftos *BMovingFundsTimedOutSubscription) Pipe( }) } -func (b *Bridge) watchMovingFundsTimedOut( - sink chan *abi.BridgeMovingFundsTimedOut, +func (b *Bridge) watchNewWalletRegistered( + sink chan *abi.BridgeNewWalletRegistered, + ecdsaWalletIDFilter [][32]byte, walletPubKeyHashFilter [][20]byte, ) event.Subscription { subscribeFn := func(ctx context.Context) (event.Subscription, error) { - return b.contract.WatchMovingFundsTimedOut( + return b.contract.WatchNewWalletRegistered( &bind.WatchOpts{Context: ctx}, sink, + ecdsaWalletIDFilter, walletPubKeyHashFilter, ) } thresholdViolatedFn := func(elapsed time.Duration) { bLogger.Warnf( - "subscription to event MovingFundsTimedOut had to be "+ + "subscription to event NewWalletRegistered had to be "+ "retried [%s] since the last attempt; please inspect "+ "host chain connectivity", elapsed, @@ -10200,7 +12065,7 @@ func (b *Bridge) watchMovingFundsTimedOut( subscriptionFailedFn := func(err error) { bLogger.Errorf( - "subscription to event MovingFundsTimedOut failed "+ + "subscription to event NewWalletRegistered failed "+ "with error: [%v]; resubscription attempt will be "+ "performed", err, @@ -10216,26 +12081,28 @@ func (b *Bridge) watchMovingFundsTimedOut( ) } -func (b *Bridge) PastMovingFundsTimedOutEvents( +func (b *Bridge) PastNewWalletRegisteredEvents( startBlock uint64, endBlock *uint64, + ecdsaWalletIDFilter [][32]byte, walletPubKeyHashFilter [][20]byte, -) ([]*abi.BridgeMovingFundsTimedOut, error) { - iterator, err := b.contract.FilterMovingFundsTimedOut( +) ([]*abi.BridgeNewWalletRegistered, error) { + iterator, err := b.contract.FilterNewWalletRegistered( &bind.FilterOpts{ Start: startBlock, End: endBlock, }, + ecdsaWalletIDFilter, walletPubKeyHashFilter, ) if err != nil { return nil, fmt.Errorf( - "error retrieving past MovingFundsTimedOut events: [%v]", + "error retrieving past NewWalletRegistered events: [%v]", err, ) } - events := make([]*abi.BridgeMovingFundsTimedOut, 0) + events := make([]*abi.BridgeNewWalletRegistered, 0) for iterator.Next() { event := iterator.Event @@ -10245,10 +12112,12 @@ func (b *Bridge) PastMovingFundsTimedOutEvents( return events, nil } -func (b *Bridge) MovingFundsTimeoutResetEvent( +func (b *Bridge) NewWalletRegisteredV2Event( opts *ethereum.SubscribeOpts, + walletIDFilter [][32]byte, + ecdsaWalletIDFilter [][32]byte, walletPubKeyHashFilter [][20]byte, -) *BMovingFundsTimeoutResetSubscription { +) *BNewWalletRegisteredV2Subscription { if opts == nil { opts = new(ethereum.SubscribeOpts) } @@ -10259,28 +12128,34 @@ func (b *Bridge) MovingFundsTimeoutResetEvent( opts.PastBlocks = chainutil.DefaultSubscribeOptsPastBlocks } - return &BMovingFundsTimeoutResetSubscription{ + return &BNewWalletRegisteredV2Subscription{ b, opts, + walletIDFilter, + ecdsaWalletIDFilter, walletPubKeyHashFilter, } } -type BMovingFundsTimeoutResetSubscription struct { +type BNewWalletRegisteredV2Subscription struct { contract *Bridge opts *ethereum.SubscribeOpts + walletIDFilter [][32]byte + ecdsaWalletIDFilter [][32]byte walletPubKeyHashFilter [][20]byte } -type bridgeMovingFundsTimeoutResetFunc func( +type bridgeNewWalletRegisteredV2Func func( + WalletID [32]byte, + EcdsaWalletID [32]byte, WalletPubKeyHash [20]byte, blockNumber uint64, ) -func (mftrs *BMovingFundsTimeoutResetSubscription) OnEvent( - handler bridgeMovingFundsTimeoutResetFunc, +func (nwrvs *BNewWalletRegisteredV2Subscription) OnEvent( + handler bridgeNewWalletRegisteredV2Func, ) subscription.EventSubscription { - eventChan := make(chan *abi.BridgeMovingFundsTimeoutReset) + eventChan := make(chan *abi.BridgeNewWalletRegisteredV2) ctx, cancelCtx := context.WithCancel(context.Background()) go func() { @@ -10290,6 +12165,8 @@ func (mftrs *BMovingFundsTimeoutResetSubscription) OnEvent( return case event := <-eventChan: handler( + event.WalletID, + event.EcdsaWalletID, event.WalletPubKeyHash, event.Raw.BlockNumber, ) @@ -10297,43 +12174,45 @@ func (mftrs *BMovingFundsTimeoutResetSubscription) OnEvent( } }() - sub := mftrs.Pipe(eventChan) + sub := nwrvs.Pipe(eventChan) return subscription.NewEventSubscription(func() { sub.Unsubscribe() cancelCtx() }) } -func (mftrs *BMovingFundsTimeoutResetSubscription) Pipe( - sink chan *abi.BridgeMovingFundsTimeoutReset, +func (nwrvs *BNewWalletRegisteredV2Subscription) Pipe( + sink chan *abi.BridgeNewWalletRegisteredV2, ) subscription.EventSubscription { ctx, cancelCtx := context.WithCancel(context.Background()) go func() { - ticker := time.NewTicker(mftrs.opts.Tick) + ticker := time.NewTicker(nwrvs.opts.Tick) defer ticker.Stop() for { select { case <-ctx.Done(): return case <-ticker.C: - lastBlock, err := mftrs.contract.blockCounter.CurrentBlock() + lastBlock, err := nwrvs.contract.blockCounter.CurrentBlock() if err != nil { bLogger.Errorf( "subscription failed to pull events: [%v]", err, ) } - fromBlock := lastBlock - mftrs.opts.PastBlocks + fromBlock := lastBlock - nwrvs.opts.PastBlocks bLogger.Infof( - "subscription monitoring fetching past MovingFundsTimeoutReset events "+ + "subscription monitoring fetching past NewWalletRegisteredV2 events "+ "starting from block [%v]", fromBlock, ) - events, err := mftrs.contract.PastMovingFundsTimeoutResetEvents( + events, err := nwrvs.contract.PastNewWalletRegisteredV2Events( fromBlock, nil, - mftrs.walletPubKeyHashFilter, + nwrvs.walletIDFilter, + nwrvs.ecdsaWalletIDFilter, + nwrvs.walletPubKeyHashFilter, ) if err != nil { bLogger.Errorf( @@ -10343,7 +12222,7 @@ func (mftrs *BMovingFundsTimeoutResetSubscription) Pipe( continue } bLogger.Infof( - "subscription monitoring fetched [%v] past MovingFundsTimeoutReset events", + "subscription monitoring fetched [%v] past NewWalletRegisteredV2 events", len(events), ) @@ -10354,9 +12233,11 @@ func (mftrs *BMovingFundsTimeoutResetSubscription) Pipe( } }() - sub := mftrs.contract.watchMovingFundsTimeoutReset( + sub := nwrvs.contract.watchNewWalletRegisteredV2( sink, - mftrs.walletPubKeyHashFilter, + nwrvs.walletIDFilter, + nwrvs.ecdsaWalletIDFilter, + nwrvs.walletPubKeyHashFilter, ) return subscription.NewEventSubscription(func() { @@ -10365,21 +12246,25 @@ func (mftrs *BMovingFundsTimeoutResetSubscription) Pipe( }) } -func (b *Bridge) watchMovingFundsTimeoutReset( - sink chan *abi.BridgeMovingFundsTimeoutReset, +func (b *Bridge) watchNewWalletRegisteredV2( + sink chan *abi.BridgeNewWalletRegisteredV2, + walletIDFilter [][32]byte, + ecdsaWalletIDFilter [][32]byte, walletPubKeyHashFilter [][20]byte, ) event.Subscription { subscribeFn := func(ctx context.Context) (event.Subscription, error) { - return b.contract.WatchMovingFundsTimeoutReset( + return b.contract.WatchNewWalletRegisteredV2( &bind.WatchOpts{Context: ctx}, sink, + walletIDFilter, + ecdsaWalletIDFilter, walletPubKeyHashFilter, ) } thresholdViolatedFn := func(elapsed time.Duration) { bLogger.Warnf( - "subscription to event MovingFundsTimeoutReset had to be "+ + "subscription to event NewWalletRegisteredV2 had to be "+ "retried [%s] since the last attempt; please inspect "+ "host chain connectivity", elapsed, @@ -10388,7 +12273,7 @@ func (b *Bridge) watchMovingFundsTimeoutReset( subscriptionFailedFn := func(err error) { bLogger.Errorf( - "subscription to event MovingFundsTimeoutReset failed "+ + "subscription to event NewWalletRegisteredV2 failed "+ "with error: [%v]; resubscription attempt will be "+ "performed", err, @@ -10404,26 +12289,30 @@ func (b *Bridge) watchMovingFundsTimeoutReset( ) } -func (b *Bridge) PastMovingFundsTimeoutResetEvents( +func (b *Bridge) PastNewWalletRegisteredV2Events( startBlock uint64, endBlock *uint64, + walletIDFilter [][32]byte, + ecdsaWalletIDFilter [][32]byte, walletPubKeyHashFilter [][20]byte, -) ([]*abi.BridgeMovingFundsTimeoutReset, error) { - iterator, err := b.contract.FilterMovingFundsTimeoutReset( +) ([]*abi.BridgeNewWalletRegisteredV2, error) { + iterator, err := b.contract.FilterNewWalletRegisteredV2( &bind.FilterOpts{ Start: startBlock, End: endBlock, }, + walletIDFilter, + ecdsaWalletIDFilter, walletPubKeyHashFilter, ) if err != nil { return nil, fmt.Errorf( - "error retrieving past MovingFundsTimeoutReset events: [%v]", + "error retrieving past NewWalletRegisteredV2 events: [%v]", err, ) } - events := make([]*abi.BridgeMovingFundsTimeoutReset, 0) + events := make([]*abi.BridgeNewWalletRegisteredV2, 0) for iterator.Next() { event := iterator.Event @@ -10433,11 +12322,9 @@ func (b *Bridge) PastMovingFundsTimeoutResetEvents( return events, nil } -func (b *Bridge) NewWalletRegisteredEvent( +func (b *Bridge) NewWalletRequestedEvent( opts *ethereum.SubscribeOpts, - ecdsaWalletIDFilter [][32]byte, - walletPubKeyHashFilter [][20]byte, -) *BNewWalletRegisteredSubscription { +) *BNewWalletRequestedSubscription { if opts == nil { opts = new(ethereum.SubscribeOpts) } @@ -10448,31 +12335,25 @@ func (b *Bridge) NewWalletRegisteredEvent( opts.PastBlocks = chainutil.DefaultSubscribeOptsPastBlocks } - return &BNewWalletRegisteredSubscription{ + return &BNewWalletRequestedSubscription{ b, opts, - ecdsaWalletIDFilter, - walletPubKeyHashFilter, } } -type BNewWalletRegisteredSubscription struct { - contract *Bridge - opts *ethereum.SubscribeOpts - ecdsaWalletIDFilter [][32]byte - walletPubKeyHashFilter [][20]byte +type BNewWalletRequestedSubscription struct { + contract *Bridge + opts *ethereum.SubscribeOpts } -type bridgeNewWalletRegisteredFunc func( - EcdsaWalletID [32]byte, - WalletPubKeyHash [20]byte, +type bridgeNewWalletRequestedFunc func( blockNumber uint64, ) -func (nwrs *BNewWalletRegisteredSubscription) OnEvent( - handler bridgeNewWalletRegisteredFunc, +func (nwrs *BNewWalletRequestedSubscription) OnEvent( + handler bridgeNewWalletRequestedFunc, ) subscription.EventSubscription { - eventChan := make(chan *abi.BridgeNewWalletRegistered) + eventChan := make(chan *abi.BridgeNewWalletRequested) ctx, cancelCtx := context.WithCancel(context.Background()) go func() { @@ -10482,8 +12363,6 @@ func (nwrs *BNewWalletRegisteredSubscription) OnEvent( return case event := <-eventChan: handler( - event.EcdsaWalletID, - event.WalletPubKeyHash, event.Raw.BlockNumber, ) } @@ -10497,8 +12376,8 @@ func (nwrs *BNewWalletRegisteredSubscription) OnEvent( }) } -func (nwrs *BNewWalletRegisteredSubscription) Pipe( - sink chan *abi.BridgeNewWalletRegistered, +func (nwrs *BNewWalletRequestedSubscription) Pipe( + sink chan *abi.BridgeNewWalletRequested, ) subscription.EventSubscription { ctx, cancelCtx := context.WithCancel(context.Background()) go func() { @@ -10519,15 +12398,13 @@ func (nwrs *BNewWalletRegisteredSubscription) Pipe( fromBlock := lastBlock - nwrs.opts.PastBlocks bLogger.Infof( - "subscription monitoring fetching past NewWalletRegistered events "+ + "subscription monitoring fetching past NewWalletRequested events "+ "starting from block [%v]", fromBlock, ) - events, err := nwrs.contract.PastNewWalletRegisteredEvents( + events, err := nwrs.contract.PastNewWalletRequestedEvents( fromBlock, nil, - nwrs.ecdsaWalletIDFilter, - nwrs.walletPubKeyHashFilter, ) if err != nil { bLogger.Errorf( @@ -10537,7 +12414,7 @@ func (nwrs *BNewWalletRegisteredSubscription) Pipe( continue } bLogger.Infof( - "subscription monitoring fetched [%v] past NewWalletRegistered events", + "subscription monitoring fetched [%v] past NewWalletRequested events", len(events), ) @@ -10548,10 +12425,8 @@ func (nwrs *BNewWalletRegisteredSubscription) Pipe( } }() - sub := nwrs.contract.watchNewWalletRegistered( + sub := nwrs.contract.watchNewWalletRequested( sink, - nwrs.ecdsaWalletIDFilter, - nwrs.walletPubKeyHashFilter, ) return subscription.NewEventSubscription(func() { @@ -10560,23 +12435,19 @@ func (nwrs *BNewWalletRegisteredSubscription) Pipe( }) } -func (b *Bridge) watchNewWalletRegistered( - sink chan *abi.BridgeNewWalletRegistered, - ecdsaWalletIDFilter [][32]byte, - walletPubKeyHashFilter [][20]byte, +func (b *Bridge) watchNewWalletRequested( + sink chan *abi.BridgeNewWalletRequested, ) event.Subscription { subscribeFn := func(ctx context.Context) (event.Subscription, error) { - return b.contract.WatchNewWalletRegistered( + return b.contract.WatchNewWalletRequested( &bind.WatchOpts{Context: ctx}, sink, - ecdsaWalletIDFilter, - walletPubKeyHashFilter, ) } thresholdViolatedFn := func(elapsed time.Duration) { bLogger.Warnf( - "subscription to event NewWalletRegistered had to be "+ + "subscription to event NewWalletRequested had to be "+ "retried [%s] since the last attempt; please inspect "+ "host chain connectivity", elapsed, @@ -10585,7 +12456,7 @@ func (b *Bridge) watchNewWalletRegistered( subscriptionFailedFn := func(err error) { bLogger.Errorf( - "subscription to event NewWalletRegistered failed "+ + "subscription to event NewWalletRequested failed "+ "with error: [%v]; resubscription attempt will be "+ "performed", err, @@ -10601,28 +12472,24 @@ func (b *Bridge) watchNewWalletRegistered( ) } -func (b *Bridge) PastNewWalletRegisteredEvents( +func (b *Bridge) PastNewWalletRequestedEvents( startBlock uint64, endBlock *uint64, - ecdsaWalletIDFilter [][32]byte, - walletPubKeyHashFilter [][20]byte, -) ([]*abi.BridgeNewWalletRegistered, error) { - iterator, err := b.contract.FilterNewWalletRegistered( +) ([]*abi.BridgeNewWalletRequested, error) { + iterator, err := b.contract.FilterNewWalletRequested( &bind.FilterOpts{ Start: startBlock, End: endBlock, }, - ecdsaWalletIDFilter, - walletPubKeyHashFilter, ) if err != nil { return nil, fmt.Errorf( - "error retrieving past NewWalletRegistered events: [%v]", + "error retrieving past NewWalletRequested events: [%v]", err, ) } - events := make([]*abi.BridgeNewWalletRegistered, 0) + events := make([]*abi.BridgeNewWalletRequested, 0) for iterator.Next() { event := iterator.Event @@ -10632,12 +12499,10 @@ func (b *Bridge) PastNewWalletRegisteredEvents( return events, nil } -func (b *Bridge) NewWalletRegisteredV2Event( +func (b *Bridge) NewWalletSchemeSetEvent( opts *ethereum.SubscribeOpts, - walletIDFilter [][32]byte, - ecdsaWalletIDFilter [][32]byte, - walletPubKeyHashFilter [][20]byte, -) *BNewWalletRegisteredV2Subscription { + schemeFilter []uint8, +) *BNewWalletSchemeSetSubscription { if opts == nil { opts = new(ethereum.SubscribeOpts) } @@ -10648,34 +12513,28 @@ func (b *Bridge) NewWalletRegisteredV2Event( opts.PastBlocks = chainutil.DefaultSubscribeOptsPastBlocks } - return &BNewWalletRegisteredV2Subscription{ + return &BNewWalletSchemeSetSubscription{ b, opts, - walletIDFilter, - ecdsaWalletIDFilter, - walletPubKeyHashFilter, + schemeFilter, } } - -type BNewWalletRegisteredV2Subscription struct { - contract *Bridge - opts *ethereum.SubscribeOpts - walletIDFilter [][32]byte - ecdsaWalletIDFilter [][32]byte - walletPubKeyHashFilter [][20]byte -} - -type bridgeNewWalletRegisteredV2Func func( - WalletID [32]byte, - EcdsaWalletID [32]byte, - WalletPubKeyHash [20]byte, + +type BNewWalletSchemeSetSubscription struct { + contract *Bridge + opts *ethereum.SubscribeOpts + schemeFilter []uint8 +} + +type bridgeNewWalletSchemeSetFunc func( + Scheme uint8, blockNumber uint64, ) -func (nwrvs *BNewWalletRegisteredV2Subscription) OnEvent( - handler bridgeNewWalletRegisteredV2Func, +func (nwsss *BNewWalletSchemeSetSubscription) OnEvent( + handler bridgeNewWalletSchemeSetFunc, ) subscription.EventSubscription { - eventChan := make(chan *abi.BridgeNewWalletRegisteredV2) + eventChan := make(chan *abi.BridgeNewWalletSchemeSet) ctx, cancelCtx := context.WithCancel(context.Background()) go func() { @@ -10685,54 +12544,50 @@ func (nwrvs *BNewWalletRegisteredV2Subscription) OnEvent( return case event := <-eventChan: handler( - event.WalletID, - event.EcdsaWalletID, - event.WalletPubKeyHash, + event.Scheme, event.Raw.BlockNumber, ) } } }() - sub := nwrvs.Pipe(eventChan) + sub := nwsss.Pipe(eventChan) return subscription.NewEventSubscription(func() { sub.Unsubscribe() cancelCtx() }) } -func (nwrvs *BNewWalletRegisteredV2Subscription) Pipe( - sink chan *abi.BridgeNewWalletRegisteredV2, +func (nwsss *BNewWalletSchemeSetSubscription) Pipe( + sink chan *abi.BridgeNewWalletSchemeSet, ) subscription.EventSubscription { ctx, cancelCtx := context.WithCancel(context.Background()) go func() { - ticker := time.NewTicker(nwrvs.opts.Tick) + ticker := time.NewTicker(nwsss.opts.Tick) defer ticker.Stop() for { select { case <-ctx.Done(): return case <-ticker.C: - lastBlock, err := nwrvs.contract.blockCounter.CurrentBlock() + lastBlock, err := nwsss.contract.blockCounter.CurrentBlock() if err != nil { bLogger.Errorf( "subscription failed to pull events: [%v]", err, ) } - fromBlock := lastBlock - nwrvs.opts.PastBlocks + fromBlock := lastBlock - nwsss.opts.PastBlocks bLogger.Infof( - "subscription monitoring fetching past NewWalletRegisteredV2 events "+ + "subscription monitoring fetching past NewWalletSchemeSet events "+ "starting from block [%v]", fromBlock, ) - events, err := nwrvs.contract.PastNewWalletRegisteredV2Events( + events, err := nwsss.contract.PastNewWalletSchemeSetEvents( fromBlock, nil, - nwrvs.walletIDFilter, - nwrvs.ecdsaWalletIDFilter, - nwrvs.walletPubKeyHashFilter, + nwsss.schemeFilter, ) if err != nil { bLogger.Errorf( @@ -10742,7 +12597,7 @@ func (nwrvs *BNewWalletRegisteredV2Subscription) Pipe( continue } bLogger.Infof( - "subscription monitoring fetched [%v] past NewWalletRegisteredV2 events", + "subscription monitoring fetched [%v] past NewWalletSchemeSet events", len(events), ) @@ -10753,11 +12608,9 @@ func (nwrvs *BNewWalletRegisteredV2Subscription) Pipe( } }() - sub := nwrvs.contract.watchNewWalletRegisteredV2( + sub := nwsss.contract.watchNewWalletSchemeSet( sink, - nwrvs.walletIDFilter, - nwrvs.ecdsaWalletIDFilter, - nwrvs.walletPubKeyHashFilter, + nwsss.schemeFilter, ) return subscription.NewEventSubscription(func() { @@ -10766,25 +12619,21 @@ func (nwrvs *BNewWalletRegisteredV2Subscription) Pipe( }) } -func (b *Bridge) watchNewWalletRegisteredV2( - sink chan *abi.BridgeNewWalletRegisteredV2, - walletIDFilter [][32]byte, - ecdsaWalletIDFilter [][32]byte, - walletPubKeyHashFilter [][20]byte, +func (b *Bridge) watchNewWalletSchemeSet( + sink chan *abi.BridgeNewWalletSchemeSet, + schemeFilter []uint8, ) event.Subscription { subscribeFn := func(ctx context.Context) (event.Subscription, error) { - return b.contract.WatchNewWalletRegisteredV2( + return b.contract.WatchNewWalletSchemeSet( &bind.WatchOpts{Context: ctx}, sink, - walletIDFilter, - ecdsaWalletIDFilter, - walletPubKeyHashFilter, + schemeFilter, ) } thresholdViolatedFn := func(elapsed time.Duration) { bLogger.Warnf( - "subscription to event NewWalletRegisteredV2 had to be "+ + "subscription to event NewWalletSchemeSet had to be "+ "retried [%s] since the last attempt; please inspect "+ "host chain connectivity", elapsed, @@ -10793,7 +12642,7 @@ func (b *Bridge) watchNewWalletRegisteredV2( subscriptionFailedFn := func(err error) { bLogger.Errorf( - "subscription to event NewWalletRegisteredV2 failed "+ + "subscription to event NewWalletSchemeSet failed "+ "with error: [%v]; resubscription attempt will be "+ "performed", err, @@ -10809,30 +12658,26 @@ func (b *Bridge) watchNewWalletRegisteredV2( ) } -func (b *Bridge) PastNewWalletRegisteredV2Events( +func (b *Bridge) PastNewWalletSchemeSetEvents( startBlock uint64, endBlock *uint64, - walletIDFilter [][32]byte, - ecdsaWalletIDFilter [][32]byte, - walletPubKeyHashFilter [][20]byte, -) ([]*abi.BridgeNewWalletRegisteredV2, error) { - iterator, err := b.contract.FilterNewWalletRegisteredV2( + schemeFilter []uint8, +) ([]*abi.BridgeNewWalletSchemeSet, error) { + iterator, err := b.contract.FilterNewWalletSchemeSet( &bind.FilterOpts{ Start: startBlock, End: endBlock, }, - walletIDFilter, - ecdsaWalletIDFilter, - walletPubKeyHashFilter, + schemeFilter, ) if err != nil { return nil, fmt.Errorf( - "error retrieving past NewWalletRegisteredV2 events: [%v]", + "error retrieving past NewWalletSchemeSet events: [%v]", err, ) } - events := make([]*abi.BridgeNewWalletRegisteredV2, 0) + events := make([]*abi.BridgeNewWalletSchemeSet, 0) for iterator.Next() { event := iterator.Event @@ -10842,9 +12687,9 @@ func (b *Bridge) PastNewWalletRegisteredV2Events( return events, nil } -func (b *Bridge) NewWalletRequestedEvent( +func (b *Bridge) P2TRFraudRouterSetEvent( opts *ethereum.SubscribeOpts, -) *BNewWalletRequestedSubscription { +) *BP2TRFraudRouterSetSubscription { if opts == nil { opts = new(ethereum.SubscribeOpts) } @@ -10855,25 +12700,26 @@ func (b *Bridge) NewWalletRequestedEvent( opts.PastBlocks = chainutil.DefaultSubscribeOptsPastBlocks } - return &BNewWalletRequestedSubscription{ + return &BP2TRFraudRouterSetSubscription{ b, opts, } } -type BNewWalletRequestedSubscription struct { +type BP2TRFraudRouterSetSubscription struct { contract *Bridge opts *ethereum.SubscribeOpts } -type bridgeNewWalletRequestedFunc func( +type bridgeP2TRFraudRouterSetFunc func( + P2trFraudRouter common.Address, blockNumber uint64, ) -func (nwrs *BNewWalletRequestedSubscription) OnEvent( - handler bridgeNewWalletRequestedFunc, +func (ptrfrss *BP2TRFraudRouterSetSubscription) OnEvent( + handler bridgeP2TRFraudRouterSetFunc, ) subscription.EventSubscription { - eventChan := make(chan *abi.BridgeNewWalletRequested) + eventChan := make(chan *abi.BridgeP2TRFraudRouterSet) ctx, cancelCtx := context.WithCancel(context.Background()) go func() { @@ -10883,46 +12729,47 @@ func (nwrs *BNewWalletRequestedSubscription) OnEvent( return case event := <-eventChan: handler( + event.P2trFraudRouter, event.Raw.BlockNumber, ) } } }() - sub := nwrs.Pipe(eventChan) + sub := ptrfrss.Pipe(eventChan) return subscription.NewEventSubscription(func() { sub.Unsubscribe() cancelCtx() }) } -func (nwrs *BNewWalletRequestedSubscription) Pipe( - sink chan *abi.BridgeNewWalletRequested, +func (ptrfrss *BP2TRFraudRouterSetSubscription) Pipe( + sink chan *abi.BridgeP2TRFraudRouterSet, ) subscription.EventSubscription { ctx, cancelCtx := context.WithCancel(context.Background()) go func() { - ticker := time.NewTicker(nwrs.opts.Tick) + ticker := time.NewTicker(ptrfrss.opts.Tick) defer ticker.Stop() for { select { case <-ctx.Done(): return case <-ticker.C: - lastBlock, err := nwrs.contract.blockCounter.CurrentBlock() + lastBlock, err := ptrfrss.contract.blockCounter.CurrentBlock() if err != nil { bLogger.Errorf( "subscription failed to pull events: [%v]", err, ) } - fromBlock := lastBlock - nwrs.opts.PastBlocks + fromBlock := lastBlock - ptrfrss.opts.PastBlocks bLogger.Infof( - "subscription monitoring fetching past NewWalletRequested events "+ + "subscription monitoring fetching past P2TRFraudRouterSet events "+ "starting from block [%v]", fromBlock, ) - events, err := nwrs.contract.PastNewWalletRequestedEvents( + events, err := ptrfrss.contract.PastP2TRFraudRouterSetEvents( fromBlock, nil, ) @@ -10934,7 +12781,7 @@ func (nwrs *BNewWalletRequestedSubscription) Pipe( continue } bLogger.Infof( - "subscription monitoring fetched [%v] past NewWalletRequested events", + "subscription monitoring fetched [%v] past P2TRFraudRouterSet events", len(events), ) @@ -10945,7 +12792,7 @@ func (nwrs *BNewWalletRequestedSubscription) Pipe( } }() - sub := nwrs.contract.watchNewWalletRequested( + sub := ptrfrss.contract.watchP2TRFraudRouterSet( sink, ) @@ -10955,11 +12802,11 @@ func (nwrs *BNewWalletRequestedSubscription) Pipe( }) } -func (b *Bridge) watchNewWalletRequested( - sink chan *abi.BridgeNewWalletRequested, +func (b *Bridge) watchP2TRFraudRouterSet( + sink chan *abi.BridgeP2TRFraudRouterSet, ) event.Subscription { subscribeFn := func(ctx context.Context) (event.Subscription, error) { - return b.contract.WatchNewWalletRequested( + return b.contract.WatchP2TRFraudRouterSet( &bind.WatchOpts{Context: ctx}, sink, ) @@ -10967,7 +12814,7 @@ func (b *Bridge) watchNewWalletRequested( thresholdViolatedFn := func(elapsed time.Duration) { bLogger.Warnf( - "subscription to event NewWalletRequested had to be "+ + "subscription to event P2TRFraudRouterSet had to be "+ "retried [%s] since the last attempt; please inspect "+ "host chain connectivity", elapsed, @@ -10976,7 +12823,7 @@ func (b *Bridge) watchNewWalletRequested( subscriptionFailedFn := func(err error) { bLogger.Errorf( - "subscription to event NewWalletRequested failed "+ + "subscription to event P2TRFraudRouterSet failed "+ "with error: [%v]; resubscription attempt will be "+ "performed", err, @@ -10992,11 +12839,11 @@ func (b *Bridge) watchNewWalletRequested( ) } -func (b *Bridge) PastNewWalletRequestedEvents( +func (b *Bridge) PastP2TRFraudRouterSetEvents( startBlock uint64, endBlock *uint64, -) ([]*abi.BridgeNewWalletRequested, error) { - iterator, err := b.contract.FilterNewWalletRequested( +) ([]*abi.BridgeP2TRFraudRouterSet, error) { + iterator, err := b.contract.FilterP2TRFraudRouterSet( &bind.FilterOpts{ Start: startBlock, End: endBlock, @@ -11004,12 +12851,12 @@ func (b *Bridge) PastNewWalletRequestedEvents( ) if err != nil { return nil, fmt.Errorf( - "error retrieving past NewWalletRequested events: [%v]", + "error retrieving past P2TRFraudRouterSet events: [%v]", err, ) } - events := make([]*abi.BridgeNewWalletRequested, 0) + events := make([]*abi.BridgeP2TRFraudRouterSet, 0) for iterator.Next() { event := iterator.Event @@ -12345,6 +14192,223 @@ func (b *Bridge) PastSpvMaintainerStatusUpdatedEvents( return events, nil } +func (b *Bridge) TaprootDepositRevealedEvent( + opts *ethereum.SubscribeOpts, + depositorFilter []common.Address, + walletPubKeyHashFilter [][20]byte, +) *BTaprootDepositRevealedSubscription { + if opts == nil { + opts = new(ethereum.SubscribeOpts) + } + if opts.Tick == 0 { + opts.Tick = chainutil.DefaultSubscribeOptsTick + } + if opts.PastBlocks == 0 { + opts.PastBlocks = chainutil.DefaultSubscribeOptsPastBlocks + } + + return &BTaprootDepositRevealedSubscription{ + b, + opts, + depositorFilter, + walletPubKeyHashFilter, + } +} + +type BTaprootDepositRevealedSubscription struct { + contract *Bridge + opts *ethereum.SubscribeOpts + depositorFilter []common.Address + walletPubKeyHashFilter [][20]byte +} + +type bridgeTaprootDepositRevealedFunc func( + FundingTxHash [32]byte, + FundingOutputIndex uint32, + Depositor common.Address, + Amount uint64, + BlindingFactor [8]byte, + WalletPubKeyHash [20]byte, + WalletXOnlyPublicKey [32]byte, + RefundPubKeyHash [20]byte, + RefundXOnlyPublicKey [32]byte, + RefundLocktime [4]byte, + Vault common.Address, + blockNumber uint64, +) + +func (tdrs *BTaprootDepositRevealedSubscription) OnEvent( + handler bridgeTaprootDepositRevealedFunc, +) subscription.EventSubscription { + eventChan := make(chan *abi.BridgeTaprootDepositRevealed) + ctx, cancelCtx := context.WithCancel(context.Background()) + + go func() { + for { + select { + case <-ctx.Done(): + return + case event := <-eventChan: + handler( + event.FundingTxHash, + event.FundingOutputIndex, + event.Depositor, + event.Amount, + event.BlindingFactor, + event.WalletPubKeyHash, + event.WalletXOnlyPublicKey, + event.RefundPubKeyHash, + event.RefundXOnlyPublicKey, + event.RefundLocktime, + event.Vault, + event.Raw.BlockNumber, + ) + } + } + }() + + sub := tdrs.Pipe(eventChan) + return subscription.NewEventSubscription(func() { + sub.Unsubscribe() + cancelCtx() + }) +} + +func (tdrs *BTaprootDepositRevealedSubscription) Pipe( + sink chan *abi.BridgeTaprootDepositRevealed, +) subscription.EventSubscription { + ctx, cancelCtx := context.WithCancel(context.Background()) + go func() { + ticker := time.NewTicker(tdrs.opts.Tick) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + lastBlock, err := tdrs.contract.blockCounter.CurrentBlock() + if err != nil { + bLogger.Errorf( + "subscription failed to pull events: [%v]", + err, + ) + } + fromBlock := lastBlock - tdrs.opts.PastBlocks + + bLogger.Infof( + "subscription monitoring fetching past TaprootDepositRevealed events "+ + "starting from block [%v]", + fromBlock, + ) + events, err := tdrs.contract.PastTaprootDepositRevealedEvents( + fromBlock, + nil, + tdrs.depositorFilter, + tdrs.walletPubKeyHashFilter, + ) + if err != nil { + bLogger.Errorf( + "subscription failed to pull events: [%v]", + err, + ) + continue + } + bLogger.Infof( + "subscription monitoring fetched [%v] past TaprootDepositRevealed events", + len(events), + ) + + for _, event := range events { + sink <- event + } + } + } + }() + + sub := tdrs.contract.watchTaprootDepositRevealed( + sink, + tdrs.depositorFilter, + tdrs.walletPubKeyHashFilter, + ) + + return subscription.NewEventSubscription(func() { + sub.Unsubscribe() + cancelCtx() + }) +} + +func (b *Bridge) watchTaprootDepositRevealed( + sink chan *abi.BridgeTaprootDepositRevealed, + depositorFilter []common.Address, + walletPubKeyHashFilter [][20]byte, +) event.Subscription { + subscribeFn := func(ctx context.Context) (event.Subscription, error) { + return b.contract.WatchTaprootDepositRevealed( + &bind.WatchOpts{Context: ctx}, + sink, + depositorFilter, + walletPubKeyHashFilter, + ) + } + + thresholdViolatedFn := func(elapsed time.Duration) { + bLogger.Warnf( + "subscription to event TaprootDepositRevealed had to be "+ + "retried [%s] since the last attempt; please inspect "+ + "host chain connectivity", + elapsed, + ) + } + + subscriptionFailedFn := func(err error) { + bLogger.Errorf( + "subscription to event TaprootDepositRevealed failed "+ + "with error: [%v]; resubscription attempt will be "+ + "performed", + err, + ) + } + + return chainutil.WithResubscription( + chainutil.SubscriptionBackoffMax, + subscribeFn, + chainutil.SubscriptionAlertThreshold, + thresholdViolatedFn, + subscriptionFailedFn, + ) +} + +func (b *Bridge) PastTaprootDepositRevealedEvents( + startBlock uint64, + endBlock *uint64, + depositorFilter []common.Address, + walletPubKeyHashFilter [][20]byte, +) ([]*abi.BridgeTaprootDepositRevealed, error) { + iterator, err := b.contract.FilterTaprootDepositRevealed( + &bind.FilterOpts{ + Start: startBlock, + End: endBlock, + }, + depositorFilter, + walletPubKeyHashFilter, + ) + if err != nil { + return nil, fmt.Errorf( + "error retrieving past TaprootDepositRevealed events: [%v]", + err, + ) + } + + events := make([]*abi.BridgeTaprootDepositRevealed, 0) + + for iterator.Next() { + event := iterator.Event + events = append(events, event) + } + + return events, nil +} + func (b *Bridge) TreasuryUpdatedEvent( opts *ethereum.SubscribeOpts, ) *BTreasuryUpdatedSubscription { diff --git a/pkg/chain/ethereum/tbtc/gen/contract/WalletProposalValidator.go b/pkg/chain/ethereum/tbtc/gen/contract/WalletProposalValidator.go index b5d3591e01..2780682aac 100644 --- a/pkg/chain/ethereum/tbtc/gen/contract/WalletProposalValidator.go +++ b/pkg/chain/ethereum/tbtc/gen/contract/WalletProposalValidator.go @@ -585,4 +585,52 @@ func (wpv *WalletProposalValidator) ValidateRedemptionProposalAtBlock( return result, err } +func (wpv *WalletProposalValidator) ValidateTaprootDepositSweepProposal( + arg_proposal abi.WalletProposalValidatorDepositSweepProposal, + arg_depositsExtraInfo []abi.WalletProposalValidatorTaprootDepositExtraInfo, +) (bool, error) { + result, err := wpv.contract.ValidateTaprootDepositSweepProposal( + wpv.callerOptions, + arg_proposal, + arg_depositsExtraInfo, + ) + + if err != nil { + return result, wpv.errorResolver.ResolveError( + err, + wpv.callerOptions.From, + nil, + "validateTaprootDepositSweepProposal", + arg_proposal, + arg_depositsExtraInfo, + ) + } + + return result, err +} + +func (wpv *WalletProposalValidator) ValidateTaprootDepositSweepProposalAtBlock( + arg_proposal abi.WalletProposalValidatorDepositSweepProposal, + arg_depositsExtraInfo []abi.WalletProposalValidatorTaprootDepositExtraInfo, + blockNumber *big.Int, +) (bool, error) { + var result bool + + err := chainutil.CallAtBlock( + wpv.callerOptions.From, + blockNumber, + nil, + wpv.contractABI, + wpv.caller, + wpv.errorResolver, + wpv.contractAddress, + "validateTaprootDepositSweepProposal", + &result, + arg_proposal, + arg_depositsExtraInfo, + ) + + return result, err +} + // ------ Events ------- diff --git a/pkg/frost/signing/dkg_group_pubkey_extraction.go b/pkg/frost/signing/dkg_group_pubkey_extraction.go index 3dc3a8c57a..7c2c91cf4e 100644 --- a/pkg/frost/signing/dkg_group_pubkey_extraction.go +++ b/pkg/frost/signing/dkg_group_pubkey_extraction.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" + "github.com/btcsuite/btcd/btcec/v2" "github.com/keep-network/keep-core/pkg/frost" ) @@ -83,6 +84,28 @@ func ExtractDkgGroupPublicKeyFromMaterial( } } +// ExtractTaprootOutputKeyFromMaterial returns the 32-byte x-only Taproot +// output key committed to by native FROST signer material. +func ExtractTaprootOutputKeyFromMaterial( + signerMaterial *NativeSignerMaterial, +) ([]byte, error) { + if signerMaterial == nil { + return nil, fmt.Errorf("taproot output key: signer material is nil") + } + + switch signerMaterial.Format { + case NativeSignerMaterialFormatFrostUniFFIV2: + return extractDkgGroupPublicKeyFromUniFFIV2(signerMaterial) + case NativeSignerMaterialFormatFrostTBTCSignerV1: + return extractTaprootOutputKeyFromTBTCSignerV1(signerMaterial) + default: + return nil, fmt.Errorf( + "taproot output key: unsupported signer-material format [%s]", + signerMaterial.Format, + ) + } +} + func extractDkgGroupPublicKeyFromUniFFIV2( signerMaterial *NativeSignerMaterial, ) ([]byte, error) { @@ -138,3 +161,67 @@ func extractDkgGroupPublicKeyFromTBTCSignerV1( } return []byte(payload.KeyGroup), nil } + +func extractTaprootOutputKeyFromTBTCSignerV1( + signerMaterial *NativeSignerMaterial, +) ([]byte, error) { + payload, err := decodeBuildTaggedTBTCSignerMaterialPayload(signerMaterial) + if err != nil { + return nil, fmt.Errorf( + "taproot output key: decode FrostTBTCSignerV1: %w", + err, + ) + } + if payload.KeyGroupSource != NativeTBTCSignerKeyGroupSourceDKGPersisted { + return nil, fmt.Errorf( + "taproot output key: FrostTBTCSignerV1 key group source [%s] is not [%s]", + payload.KeyGroupSource, + NativeTBTCSignerKeyGroupSourceDKGPersisted, + ) + } + + outputKeyHex := payload.TaprootOutputKey + if outputKeyHex == "" { + outputKeyHex = payload.KeyGroup + } + + outputKey, err := TaprootOutputKeyFromTBTCSignerKey(outputKeyHex) + if err != nil { + return nil, fmt.Errorf( + "taproot output key: FrostTBTCSignerV1 key material is invalid: %w", + err, + ) + } + + return outputKey, nil +} + +// TaprootOutputKeyFromTBTCSignerKey converts tbtc-signer key material to the +// x-only BIP-340 output key committed to by P2TR wallet scripts. Current +// tbtc-signer DKG results expose the group verifying key as a compressed +// secp256k1 key-group handle, while older test material may already carry the +// x-only key. +func TaprootOutputKeyFromTBTCSignerKey(keyHex string) ([]byte, error) { + raw, err := hex.DecodeString(keyHex) + if err != nil { + return nil, err + } + + switch len(raw) { + case frost.OutputKeySize: + return raw, nil + case 1 + frost.OutputKeySize: + publicKey, err := btcec.ParsePubKey(raw) + if err != nil { + return nil, err + } + return publicKey.X().FillBytes(make([]byte, frost.OutputKeySize)), nil + default: + return nil, fmt.Errorf( + "must be %d-byte x-only or %d-byte compressed key, got %d bytes", + frost.OutputKeySize, + 1+frost.OutputKeySize, + len(raw), + ) + } +} diff --git a/pkg/frost/signing/dkg_group_pubkey_extraction_test.go b/pkg/frost/signing/dkg_group_pubkey_extraction_test.go index f25133b39a..b8570a92e5 100644 --- a/pkg/frost/signing/dkg_group_pubkey_extraction_test.go +++ b/pkg/frost/signing/dkg_group_pubkey_extraction_test.go @@ -139,6 +139,113 @@ func TestExtractDkgGroupPublicKey_FrostTBTCSignerV1_ReturnsKeyGroupBytes(t *test } } +func TestExtractTaprootOutputKey_FrostTBTCSignerV1_DKGPersistedHexDecodes( + t *testing.T, +) { + const hexKey = "0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20" + payload, _ := json.Marshal(&NativeTBTCSignerMaterialPayload{ + KeyGroup: hexKey, + KeyGroupSource: NativeTBTCSignerKeyGroupSourceDKGPersisted, + }) + mat := &NativeSignerMaterial{ + Format: NativeSignerMaterialFormatFrostTBTCSignerV1, + Payload: payload, + } + + got, err := ExtractTaprootOutputKeyFromMaterial(mat) + if err != nil { + t.Fatalf("extract: %v", err) + } + want, _ := hex.DecodeString(hexKey) + if !bytes.Equal(got, want) { + t.Fatalf( + "taproot output key mismatch: got %x, want %x", + got, + want, + ) + } +} + +func TestExtractTaprootOutputKey_FrostTBTCSignerV1_DKGPersistedCompressedKeyGroup( + t *testing.T, +) { + const compressedKey = "0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798" + const xOnlyKey = "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798" + + payload, _ := json.Marshal(&NativeTBTCSignerMaterialPayload{ + KeyGroup: compressedKey, + KeyGroupSource: NativeTBTCSignerKeyGroupSourceDKGPersisted, + }) + mat := &NativeSignerMaterial{ + Format: NativeSignerMaterialFormatFrostTBTCSignerV1, + Payload: payload, + } + + got, err := ExtractTaprootOutputKeyFromMaterial(mat) + if err != nil { + t.Fatalf("extract: %v", err) + } + want, _ := hex.DecodeString(xOnlyKey) + if !bytes.Equal(got, want) { + t.Fatalf( + "taproot output key mismatch: got %x, want %x", + got, + want, + ) + } +} + +func TestExtractTaprootOutputKey_FrostTBTCSignerV1_DKGPersistedUsesExplicitOutputKey( + t *testing.T, +) { + const compressedKey = "0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798" + const outputKey = "0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20" + + payload, _ := json.Marshal(&NativeTBTCSignerMaterialPayload{ + KeyGroup: compressedKey, + TaprootOutputKey: outputKey, + KeyGroupSource: NativeTBTCSignerKeyGroupSourceDKGPersisted, + }) + mat := &NativeSignerMaterial{ + Format: NativeSignerMaterialFormatFrostTBTCSignerV1, + Payload: payload, + } + + got, err := ExtractTaprootOutputKeyFromMaterial(mat) + if err != nil { + t.Fatalf("extract: %v", err) + } + want, _ := hex.DecodeString(outputKey) + if !bytes.Equal(got, want) { + t.Fatalf( + "taproot output key mismatch: got %x, want %x", + got, + want, + ) + } +} + +func TestExtractTaprootOutputKey_FrostTBTCSignerV1_RejectsNonDKGSource( + t *testing.T, +) { + payload, _ := json.Marshal(&NativeTBTCSignerMaterialPayload{ + KeyGroup: strings.Repeat("11", 32), + KeyGroupSource: NativeTBTCSignerKeyGroupSourceLegacyWalletPubKey, + }) + mat := &NativeSignerMaterial{ + Format: NativeSignerMaterialFormatFrostTBTCSignerV1, + Payload: payload, + } + + _, err := ExtractTaprootOutputKeyFromMaterial(mat) + if err == nil { + t.Fatal("expected non-DKG source rejection") + } + if !strings.Contains(err.Error(), NativeTBTCSignerKeyGroupSourceDKGPersisted) { + t.Fatalf("error should mention persisted DKG source: [%v]", err) + } +} + func TestExtractDkgGroupPublicKey_FrostTBTCSignerV1_DeterministicAcrossCalls(t *testing.T) { payload, _ := json.Marshal(&NativeTBTCSignerMaterialPayload{ KeyGroup: "deterministic-group", diff --git a/pkg/frost/signing/native_ffi_executor_adapter.go b/pkg/frost/signing/native_ffi_executor_adapter.go index 4ff3d486ea..1c6345a97a 100644 --- a/pkg/frost/signing/native_ffi_executor_adapter.go +++ b/pkg/frost/signing/native_ffi_executor_adapter.go @@ -22,6 +22,7 @@ type NativeExecutionFFISigningRequest struct { Channel net.BroadcastChannel MembershipValidator *group.MembershipValidator SignerMaterial *NativeSignerMaterial + TaprootMerkleRoot *[32]byte Attempt *Attempt } @@ -94,6 +95,7 @@ func (nefea *nativeExecutionFFIExecutorAdapter) Execute( Channel: request.Channel, MembershipValidator: request.MembershipValidator, SignerMaterial: signerMaterial, + TaprootMerkleRoot: cloneTaprootMerkleRoot(request.TaprootMerkleRoot), Attempt: cloneAttempt(request.Attempt), } @@ -137,3 +139,14 @@ func (nefea *nativeExecutionFFIExecutorAdapter) RegisterUnmarshallers( ) { nefea.primitive.RegisterUnmarshallers(channel) } + +func cloneTaprootMerkleRoot(taprootMerkleRoot *[32]byte) *[32]byte { + if taprootMerkleRoot == nil { + return nil + } + + result := new([32]byte) + copy(result[:], taprootMerkleRoot[:]) + + return result +} diff --git a/pkg/frost/signing/native_ffi_primitive_transitional_frost_native.go b/pkg/frost/signing/native_ffi_primitive_transitional_frost_native.go index 659d842aaf..e481b06785 100644 --- a/pkg/frost/signing/native_ffi_primitive_transitional_frost_native.go +++ b/pkg/frost/signing/native_ffi_primitive_transitional_frost_native.go @@ -255,7 +255,8 @@ func (btlcnnefsp *buildTaggedLegacyCompatibleNativeExecutionFFISigningPrimitive) ) } - dkgParticipants, dkgThreshold, err := buildTaggedTBTCSignerRunDKGInputsForIncludedMembers( + dkgParticipants, dkgThreshold, err := buildTaggedTBTCSignerRunDKGInputsForPayload( + payload, request, includedMembersIndexes, ) @@ -270,10 +271,12 @@ func (btlcnnefsp *buildTaggedLegacyCompatibleNativeExecutionFFISigningPrimitive) ) } - dkgResult, err := nativeEngine.RunDKG( + dkgResult, err := runNativeTBTCSignerDKG( + nativeEngine, request.SessionID, dkgParticipants, dkgThreshold, + payload.DKGSeedHex, ) if err != nil { return btlcnnefsp.fallbackTBTCSignerLegacySigning( @@ -485,6 +488,46 @@ func buildTaggedTBTCSignerRunDKGInputs( ) } +func buildTaggedTBTCSignerRunDKGInputsForPayload( + payload *NativeTBTCSignerMaterialPayload, + request *NativeExecutionFFISigningRequest, + includedMembersIndexes []group.MemberIndex, +) ([]NativeTBTCSignerDKGParticipant, uint16, error) { + if payload != nil && + payload.KeyGroupSource == NativeTBTCSignerKeyGroupSourceDKGPersisted { + if len(payload.DKGParticipants) < 2 { + return nil, 0, fmt.Errorf( + "persisted tbtc-signer DKG participants are insufficient", + ) + } + if payload.DKGThreshold == 0 { + return nil, 0, fmt.Errorf( + "persisted tbtc-signer DKG threshold is zero", + ) + } + if int(payload.DKGThreshold) > len(payload.DKGParticipants) { + return nil, 0, fmt.Errorf( + "persisted tbtc-signer DKG threshold exceeds participant count: [%v] > [%v]", + payload.DKGThreshold, + len(payload.DKGParticipants), + ) + } + + participants := make( + []NativeTBTCSignerDKGParticipant, + len(payload.DKGParticipants), + ) + copy(participants, payload.DKGParticipants) + + return participants, payload.DKGThreshold, nil + } + + return buildTaggedTBTCSignerRunDKGInputsForIncludedMembers( + request, + includedMembersIndexes, + ) +} + func buildTaggedTBTCSignerRunDKGInputsForIncludedMembers( request *NativeExecutionFFISigningRequest, includedMembersIndexes []group.MemberIndex, @@ -535,6 +578,12 @@ func buildTaggedTBTCSignerDKGPlaceholderPublicKeyHex(identifier uint16) string { return fmt.Sprintf("02%04x", identifier) } +// NativeTBTCSignerDKGPlaceholderPublicKeyHex returns the transitional +// placeholder public key used by tbtc-signer dealer-DKG requests. +func NativeTBTCSignerDKGPlaceholderPublicKeyHex(identifier uint16) string { + return buildTaggedTBTCSignerDKGPlaceholderPublicKeyHex(identifier) +} + func buildTaggedTBTCSignerRoundKeyGroup( payload *NativeTBTCSignerMaterialPayload, dkgResult *NativeTBTCSignerDKGResult, @@ -709,6 +758,7 @@ func executeBuildTaggedTBTCSignerBootstrapCoarseRoundWithSignature( messageBytes, keyGroup, signingParticipants, + request.TaprootMerkleRoot, ) if err != nil { return nil, fmt.Errorf("start sign round failed: [%w]", err) @@ -765,6 +815,7 @@ func executeBuildTaggedTBTCSignerBootstrapCoarseRoundWithSignature( signature, err := nativeEngine.FinalizeSignRound( request.SessionID, roundContributions, + request.TaprootMerkleRoot, ) if err != nil { return nil, fmt.Errorf("finalize sign round failed: [%w]", err) @@ -1153,6 +1204,13 @@ func (btlcnnefsp *buildTaggedLegacyCompatibleNativeExecutionFFISigningPrimitive) request *NativeExecutionFFISigningRequest, privateKeyShare *tecdsa.PrivateKeyShare, ) (*frost.Signature, error) { + if request.TaprootMerkleRoot != nil { + return nil, fmt.Errorf( + "%w: taproot tweaked signing requires native FROST signer support", + ErrNativeCryptographyUnavailable, + ) + } + if privateKeyShare == nil { return nil, fmt.Errorf("legacy private key share is nil") } @@ -1351,3 +1409,29 @@ func decodeBuildTaggedTBTCSignerLegacyPrivateKeyShare( return privateKeyShare, nil } + +func runNativeTBTCSignerDKG( + nativeEngine NativeTBTCSignerEngine, + sessionID string, + participants []NativeTBTCSignerDKGParticipant, + threshold uint16, + dkgSeedHex string, +) (*NativeTBTCSignerDKGResult, error) { + if dkgSeedHex == "" { + return nativeEngine.RunDKG(sessionID, participants, threshold) + } + + seededEngine, ok := nativeEngine.(NativeTBTCSignerSeededDKGEngine) + if !ok { + return nil, fmt.Errorf( + "native tbtc-signer engine does not support seeded RunDKG", + ) + } + + return seededEngine.RunDKGWithSeed( + sessionID, + participants, + threshold, + dkgSeedHex, + ) +} diff --git a/pkg/frost/signing/native_ffi_primitive_transitional_frost_native_test.go b/pkg/frost/signing/native_ffi_primitive_transitional_frost_native_test.go index 213931092f..0783c89b37 100644 --- a/pkg/frost/signing/native_ffi_primitive_transitional_frost_native_test.go +++ b/pkg/frost/signing/native_ffi_primitive_transitional_frost_native_test.go @@ -48,14 +48,17 @@ type mockBuildTaggedTBTCSignerEngine struct { message []byte, keyGroup string, signingParticipants []uint16, + taprootMerkleRoot *[32]byte, ) (*NativeTBTCSignerRoundState, error) - startRoundState *NativeTBTCSignerRoundState - startErr error - finalizeCalled bool - finalizeSessionID string - finalizeInputs []NativeTBTCSignerRoundContribution - finalizeSignature []byte - finalizeErr error + startTaprootMerkleRoot *[32]byte + startRoundState *NativeTBTCSignerRoundState + startErr error + finalizeCalled bool + finalizeSessionID string + finalizeTaprootMerkleRoot *[32]byte + finalizeInputs []NativeTBTCSignerRoundContribution + finalizeSignature []byte + finalizeErr error } func (mbttse *mockBuildTaggedTBTCSignerEngine) RunDKG( @@ -106,6 +109,7 @@ func (mbttse *mockBuildTaggedTBTCSignerEngine) StartSignRound( message []byte, keyGroup string, signingParticipants []uint16, + taprootMerkleRoot *[32]byte, ) (*NativeTBTCSignerRoundState, error) { mbttse.startCalled = true mbttse.startSessionID = sessionID @@ -113,6 +117,7 @@ func (mbttse *mockBuildTaggedTBTCSignerEngine) StartSignRound( mbttse.startMessage = append([]byte{}, message...) mbttse.startKeyGroup = keyGroup mbttse.startSigningParticipants = append([]uint16{}, signingParticipants...) + mbttse.startTaprootMerkleRoot = cloneTestTaprootMerkleRoot(taprootMerkleRoot) if mbttse.startErr != nil { return nil, mbttse.startErr @@ -125,6 +130,7 @@ func (mbttse *mockBuildTaggedTBTCSignerEngine) StartSignRound( message, keyGroup, signingParticipants, + taprootMerkleRoot, ) } @@ -151,9 +157,11 @@ func (mbttse *mockBuildTaggedTBTCSignerEngine) StartSignRound( func (mbttse *mockBuildTaggedTBTCSignerEngine) FinalizeSignRound( sessionID string, roundContributions []NativeTBTCSignerRoundContribution, + taprootMerkleRoot *[32]byte, ) ([]byte, error) { mbttse.finalizeCalled = true mbttse.finalizeSessionID = sessionID + mbttse.finalizeTaprootMerkleRoot = cloneTestTaprootMerkleRoot(taprootMerkleRoot) mbttse.finalizeInputs = append( []NativeTBTCSignerRoundContribution{}, roundContributions..., @@ -179,6 +187,17 @@ func (mbttse *mockBuildTaggedTBTCSignerEngine) BuildTaprootTx( return nil, errors.New("not implemented") } +func cloneTestTaprootMerkleRoot(taprootMerkleRoot *[32]byte) *[32]byte { + if taprootMerkleRoot == nil { + return nil + } + + result := new([32]byte) + copy(result[:], taprootMerkleRoot[:]) + + return result +} + type deterministicBuildTaggedTBTCSignerBootstrapRoundEngine struct { roundState *NativeTBTCSignerRoundState finalizeMutex sync.Mutex @@ -206,6 +225,7 @@ func (dbttsbre *deterministicBuildTaggedTBTCSignerBootstrapRoundEngine) StartSig _ []byte, _ string, signingParticipants []uint16, + _ *[32]byte, ) (*NativeTBTCSignerRoundState, error) { if dbttsbre.roundState != nil { if dbttsbre.roundState.OwnContribution == nil { @@ -245,6 +265,7 @@ func (dbttsbre *deterministicBuildTaggedTBTCSignerBootstrapRoundEngine) StartSig func (dbttsbre *deterministicBuildTaggedTBTCSignerBootstrapRoundEngine) FinalizeSignRound( _ string, roundContributions []NativeTBTCSignerRoundContribution, + _ *[32]byte, ) ([]byte, error) { dbttsbre.finalizeMutex.Lock() defer dbttsbre.finalizeMutex.Unlock() @@ -662,6 +683,58 @@ func TestBuildTaggedTBTCSignerRunDKGInputs(t *testing.T) { } } +func TestBuildTaggedTBTCSignerRunDKGInputsForPayload_UsesPersistedDKGInputs( + t *testing.T, +) { + persistedParticipants := []NativeTBTCSignerDKGParticipant{ + {Identifier: 1, PublicKeyHex: "020001"}, + {Identifier: 2, PublicKeyHex: "020002"}, + {Identifier: 3, PublicKeyHex: "020003"}, + } + + participants, threshold, err := buildTaggedTBTCSignerRunDKGInputsForPayload( + &NativeTBTCSignerMaterialPayload{ + KeyGroupSource: NativeTBTCSignerKeyGroupSourceDKGPersisted, + DKGParticipants: persistedParticipants, + DKGThreshold: 2, + }, + &NativeExecutionFFISigningRequest{ + GroupSize: 3, + DishonestThreshold: 1, + Attempt: &Attempt{ + Number: 1, + CoordinatorMemberIndex: 1, + IncludedMembersIndexes: []group.MemberIndex{1, 3}, + }, + }, + []group.MemberIndex{1, 3}, + ) + if err != nil { + t.Fatalf("unexpected RunDKG inputs error: [%v]", err) + } + + if threshold != 2 { + t.Fatalf("unexpected threshold: [%v]", threshold) + } + if len(participants) != len(persistedParticipants) { + t.Fatalf( + "unexpected participants count\nexpected: [%v]\nactual: [%v]", + len(persistedParticipants), + len(participants), + ) + } + for i := range participants { + if participants[i] != persistedParticipants[i] { + t.Fatalf( + "unexpected participant at index [%d]\nexpected: [%+v]\nactual: [%+v]", + i, + persistedParticipants[i], + participants[i], + ) + } + } +} + func TestBuildTaggedTBTCSignerRunDKGInputs_RejectsInvalidRequest(t *testing.T) { testCases := []struct { name string @@ -1264,6 +1337,7 @@ func TestExecuteBuildTaggedTBTCSignerBootstrapCoarseRound_FailsWhenRoundStateSig message []byte, keyGroup string, signingParticipants []uint16, + _ *[32]byte, ) (*NativeTBTCSignerRoundState, error) { return &NativeTBTCSignerRoundState{ SessionID: sessionID, @@ -1740,6 +1814,70 @@ func TestBuildTaggedLegacyCompatibleNativeExecutionFFISigningPrimitive_Sign_TBTC } } +func TestBuildTaggedLegacyCompatibleNativeExecutionFFISigningPrimitive_Sign_TBTCSignerPath_BootstrapVersion_TaprootMerkleRoot( + t *testing.T, +) { + engine := &mockBuildTaggedTBTCSignerEngine{ + version: "tbtc-signer/0.1.0-bootstrap", + finalizeSignature: buildTaggedTBTCSignerValidTestSignature(0x22), + } + UnregisterNativeTBTCSignerEngine() + t.Cleanup(UnregisterNativeTBTCSignerEngine) + + err := RegisterNativeTBTCSignerEngine(engine) + if err != nil { + t.Fatalf("unexpected registration error: [%v]", err) + } + + var taprootMerkleRoot [32]byte + taprootMerkleRoot[0] = 0xab + taprootMerkleRoot[31] = 0xcd + + primitive := &buildTaggedLegacyCompatibleNativeExecutionFFISigningPrimitive{} + + signature, err := primitive.Sign(nil, nil, &NativeExecutionFFISigningRequest{ + Message: big.NewInt(123), + SessionID: "session-1", + MemberIndex: 1, + GroupSize: 3, + DishonestThreshold: 1, + TaprootMerkleRoot: &taprootMerkleRoot, + SignerMaterial: &NativeSignerMaterial{ + Format: NativeSignerMaterialFormatFrostTBTCSignerV1, + Payload: []byte(`{"keyGroup":"group-1"}`), + }, + }) + if err != nil { + t.Fatalf("unexpected error: [%v]", err) + } + + if signature == nil { + t.Fatal("expected signature") + } + + if engine.startTaprootMerkleRoot == nil { + t.Fatal("expected StartSignRound taproot merkle root") + } + if !bytes.Equal(engine.startTaprootMerkleRoot[:], taprootMerkleRoot[:]) { + t.Fatalf( + "unexpected StartSignRound taproot merkle root\nexpected: [%x]\nactual: [%x]", + taprootMerkleRoot, + *engine.startTaprootMerkleRoot, + ) + } + + if engine.finalizeTaprootMerkleRoot == nil { + t.Fatal("expected FinalizeSignRound taproot merkle root") + } + if !bytes.Equal(engine.finalizeTaprootMerkleRoot[:], taprootMerkleRoot[:]) { + t.Fatalf( + "unexpected FinalizeSignRound taproot merkle root\nexpected: [%x]\nactual: [%x]", + taprootMerkleRoot, + *engine.finalizeTaprootMerkleRoot, + ) + } +} + func TestBuildTaggedLegacyCompatibleNativeExecutionFFISigningPrimitive_Sign_TBTCSignerPath_BootstrapVersion_InvalidCoarseSignatureFallsBack( t *testing.T, ) { @@ -2365,6 +2503,7 @@ func TestBuildTaggedLegacyCompatibleNativeExecutionFFISigningPrimitive_Sign_TBTC _ []byte, _ string, signingParticipants []uint16, + _ *[32]byte, ) (*NativeTBTCSignerRoundState, error) { observedSigningParticipants = append( observedSigningParticipants, diff --git a/pkg/frost/signing/native_frost_engine_frost_native.go b/pkg/frost/signing/native_frost_engine_frost_native.go index 757212b0e5..d01b327d71 100644 --- a/pkg/frost/signing/native_frost_engine_frost_native.go +++ b/pkg/frost/signing/native_frost_engine_frost_native.go @@ -71,6 +71,23 @@ type NativeFROSTSigningEngine interface { ) ([]byte, error) } +// NativeFROSTTaprootTweakedSigningEngine executes BIP-341 tweaked FROST +// signing operations for Taproot key-path spends that commit to a script tree. +type NativeFROSTTaprootTweakedSigningEngine interface { + SignWithTaprootTweak( + signingPackage *NativeFROSTSigningPackage, + nonces *NativeFROSTNonces, + keyPackage *NativeFROSTKeyPackage, + taprootMerkleRoot []byte, + ) (*NativeFROSTSignatureShare, error) + AggregateWithTaprootTweak( + signingPackage *NativeFROSTSigningPackage, + signatureShares []*NativeFROSTSignatureShare, + publicKeyPackage *NativeFROSTPublicKeyPackage, + taprootMerkleRoot []byte, + ) ([]byte, error) +} + // RegisterNativeFROSTSigningEngine registers the native FROST cryptographic // engine used by the tagged native-signing primitive. func RegisterNativeFROSTSigningEngine( diff --git a/pkg/frost/signing/native_frost_engine_tbtc_signer_registration_frost_native.go b/pkg/frost/signing/native_frost_engine_tbtc_signer_registration_frost_native.go index 0c5bf37374..fa81cc0ab4 100644 --- a/pkg/frost/signing/native_frost_engine_tbtc_signer_registration_frost_native.go +++ b/pkg/frost/signing/native_frost_engine_tbtc_signer_registration_frost_native.go @@ -133,6 +133,7 @@ type buildTaggedTBTCSignerRunDKGRequest struct { SessionID string `json:"session_id"` Participants []buildTaggedTBTCSignerDKGParticipant `json:"participants"` Threshold uint16 `json:"threshold"` + DKGSeedHex *string `json:"dkg_seed_hex,omitempty"` } type buildTaggedTBTCSignerDKGParticipant struct { @@ -149,11 +150,12 @@ type buildTaggedTBTCSignerRunDKGResponse struct { } type buildTaggedTBTCSignerStartSignRoundRequest struct { - SessionID string `json:"session_id"` - MemberIdentifier uint16 `json:"member_identifier"` - MessageHex string `json:"message_hex"` - KeyGroup string `json:"key_group"` - SigningParticipants []uint16 `json:"signing_participants,omitempty"` + SessionID string `json:"session_id"` + MemberIdentifier uint16 `json:"member_identifier"` + MessageHex string `json:"message_hex"` + KeyGroup string `json:"key_group"` + TaprootMerkleRootHex *string `json:"taproot_merkle_root_hex,omitempty"` + SigningParticipants []uint16 `json:"signing_participants,omitempty"` } type buildTaggedTBTCSignerStartSignRoundResponse struct { @@ -166,8 +168,9 @@ type buildTaggedTBTCSignerStartSignRoundResponse struct { } type buildTaggedTBTCSignerFinalizeSignRoundRequest struct { - SessionID string `json:"session_id"` - RoundContributions []buildTaggedTBTCSignerFinalizeRoundContribution `json:"round_contributions"` + SessionID string `json:"session_id"` + TaprootMerkleRootHex *string `json:"taproot_merkle_root_hex,omitempty"` + RoundContributions []buildTaggedTBTCSignerFinalizeRoundContribution `json:"round_contributions"` } type buildTaggedTBTCSignerFinalizeRoundContribution struct { @@ -249,12 +252,37 @@ func (bttse *buildTaggedTBTCSignerEngine) RunDKG( return decodeBuildTaggedTBTCSignerRunDKGResponse(responsePayload) } +func (bttse *buildTaggedTBTCSignerEngine) RunDKGWithSeed( + sessionID string, + participants []NativeTBTCSignerDKGParticipant, + threshold uint16, + dkgSeedHex string, +) (*NativeTBTCSignerDKGResult, error) { + requestPayload, err := buildTaggedTBTCSignerRunDKGRequestPayloadWithSeed( + sessionID, + participants, + threshold, + dkgSeedHex, + ) + if err != nil { + return nil, err + } + + responsePayload, err := callBuildTaggedTBTCSignerRunDKG(requestPayload) + if err != nil { + return nil, err + } + + return decodeBuildTaggedTBTCSignerRunDKGResponse(responsePayload) +} + func (bttse *buildTaggedTBTCSignerEngine) StartSignRound( sessionID string, memberIdentifier uint16, message []byte, keyGroup string, signingParticipants []uint16, + taprootMerkleRoot *[32]byte, ) (*NativeTBTCSignerRoundState, error) { requestPayload, err := buildTaggedTBTCSignerStartSignRoundRequestPayload( sessionID, @@ -262,6 +290,7 @@ func (bttse *buildTaggedTBTCSignerEngine) StartSignRound( message, keyGroup, signingParticipants, + taprootMerkleRoot, ) if err != nil { return nil, err @@ -278,10 +307,12 @@ func (bttse *buildTaggedTBTCSignerEngine) StartSignRound( func (bttse *buildTaggedTBTCSignerEngine) FinalizeSignRound( sessionID string, roundContributions []NativeTBTCSignerRoundContribution, + taprootMerkleRoot *[32]byte, ) ([]byte, error) { requestPayload, err := buildTaggedTBTCSignerFinalizeSignRoundRequestPayload( sessionID, roundContributions, + taprootMerkleRoot, ) if err != nil { return nil, err @@ -343,6 +374,41 @@ func buildTaggedTBTCSignerRunDKGRequestPayload( sessionID string, participants []NativeTBTCSignerDKGParticipant, threshold uint16, +) ([]byte, error) { + return buildTaggedTBTCSignerRunDKGRequestPayloadWithOptionalSeed( + sessionID, + participants, + threshold, + nil, + ) +} + +func buildTaggedTBTCSignerRunDKGRequestPayloadWithSeed( + sessionID string, + participants []NativeTBTCSignerDKGParticipant, + threshold uint16, + dkgSeedHex string, +) ([]byte, error) { + if dkgSeedHex == "" { + return nil, buildTaggedTBTCSignerOperationError( + "RunDKG", + "DKG seed hex is empty", + ) + } + + return buildTaggedTBTCSignerRunDKGRequestPayloadWithOptionalSeed( + sessionID, + participants, + threshold, + &dkgSeedHex, + ) +} + +func buildTaggedTBTCSignerRunDKGRequestPayloadWithOptionalSeed( + sessionID string, + participants []NativeTBTCSignerDKGParticipant, + threshold uint16, + dkgSeedHex *string, ) ([]byte, error) { if sessionID == "" { return nil, buildTaggedTBTCSignerOperationError( @@ -399,6 +465,7 @@ func buildTaggedTBTCSignerRunDKGRequestPayload( SessionID: sessionID, Participants: requestParticipants, Threshold: threshold, + DKGSeedHex: dkgSeedHex, } payload, err := json.Marshal(request) @@ -466,6 +533,7 @@ func buildTaggedTBTCSignerStartSignRoundRequestPayload( message []byte, keyGroup string, signingParticipants []uint16, + taprootMerkleRoot *[32]byte, ) ([]byte, error) { if sessionID == "" { return nil, buildTaggedTBTCSignerOperationError( @@ -505,12 +573,19 @@ func buildTaggedTBTCSignerStartSignRoundRequestPayload( seenParticipants[participant] = struct{}{} } + var taprootMerkleRootHex *string + if taprootMerkleRoot != nil { + encodedTaprootMerkleRoot := hex.EncodeToString(taprootMerkleRoot[:]) + taprootMerkleRootHex = &encodedTaprootMerkleRoot + } + request := buildTaggedTBTCSignerStartSignRoundRequest{ - SessionID: sessionID, - MemberIdentifier: memberIdentifier, - MessageHex: hex.EncodeToString(message), - KeyGroup: keyGroup, - SigningParticipants: append([]uint16{}, signingParticipants...), + SessionID: sessionID, + MemberIdentifier: memberIdentifier, + MessageHex: hex.EncodeToString(message), + KeyGroup: keyGroup, + TaprootMerkleRootHex: taprootMerkleRootHex, + SigningParticipants: append([]uint16{}, signingParticipants...), } payload, err := json.Marshal(request) @@ -623,6 +698,7 @@ func decodeBuildTaggedTBTCSignerStartSignRoundResponse( func buildTaggedTBTCSignerFinalizeSignRoundRequestPayload( sessionID string, roundContributions []NativeTBTCSignerRoundContribution, + taprootMerkleRoot *[32]byte, ) ([]byte, error) { if sessionID == "" { return nil, buildTaggedTBTCSignerOperationError( @@ -661,9 +737,16 @@ func buildTaggedTBTCSignerFinalizeSignRoundRequestPayload( ) } + var taprootMerkleRootHex *string + if taprootMerkleRoot != nil { + encodedTaprootMerkleRoot := hex.EncodeToString(taprootMerkleRoot[:]) + taprootMerkleRootHex = &encodedTaprootMerkleRoot + } + request := buildTaggedTBTCSignerFinalizeSignRoundRequest{ - SessionID: sessionID, - RoundContributions: payloadContributions, + SessionID: sessionID, + TaprootMerkleRootHex: taprootMerkleRootHex, + RoundContributions: payloadContributions, } payload, err := json.Marshal(request) diff --git a/pkg/frost/signing/native_frost_engine_tbtc_signer_registration_frost_native_test.go b/pkg/frost/signing/native_frost_engine_tbtc_signer_registration_frost_native_test.go index 941688275a..5792336b80 100644 --- a/pkg/frost/signing/native_frost_engine_tbtc_signer_registration_frost_native_test.go +++ b/pkg/frost/signing/native_frost_engine_tbtc_signer_registration_frost_native_test.go @@ -3,6 +3,7 @@ package signing import ( + "encoding/hex" "encoding/json" "errors" "strings" @@ -31,6 +32,7 @@ func TestRegisterBuildTaggedTBTCSignerEngine(t *testing.T) { []byte("message"), "key-group", nil, + nil, ) if err == nil { t.Fatal("expected unavailable tbtc-signer bridge error") @@ -260,6 +262,44 @@ func TestBuildTaggedTBTCSignerRunDKGRequestPayload(t *testing.T) { request.Participants[0].PublicKeyHex, ) } + + if request.DKGSeedHex != nil { + t.Fatalf("unexpected DKG seed hex: [%v]", *request.DKGSeedHex) + } +} + +func TestBuildTaggedTBTCSignerRunDKGRequestPayloadWithSeed(t *testing.T) { + payload, err := buildTaggedTBTCSignerRunDKGRequestPayloadWithSeed( + "session-1", + []NativeTBTCSignerDKGParticipant{ + { + Identifier: 1, + PublicKeyHex: "02aa", + }, + { + Identifier: 2, + PublicKeyHex: "02bb", + }, + }, + 2, + "0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20", + ) + if err != nil { + t.Fatalf("unexpected payload build error: [%v]", err) + } + + var request buildTaggedTBTCSignerRunDKGRequest + if err := json.Unmarshal(payload, &request); err != nil { + t.Fatalf("cannot decode request payload: [%v]", err) + } + + if request.DKGSeedHex == nil { + t.Fatal("expected DKG seed hex") + } + if *request.DKGSeedHex != + "0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20" { + t.Fatalf("unexpected DKG seed hex: [%v]", *request.DKGSeedHex) + } } func TestBuildTaggedTBTCSignerRunDKGRequestPayload_RejectsInvalidInput(t *testing.T) { @@ -394,6 +434,7 @@ func TestBuildTaggedTBTCSignerStartSignRoundRequestPayload(t *testing.T) { []byte{0xab, 0xcd}, "key-group-1", []uint16{1, 2, 3}, + nil, ) if err != nil { t.Fatalf("unexpected payload build error: [%v]", err) @@ -457,6 +498,44 @@ func TestBuildTaggedTBTCSignerStartSignRoundRequestPayload(t *testing.T) { } } +func TestBuildTaggedTBTCSignerStartSignRoundRequestPayload_TaprootMerkleRoot( + t *testing.T, +) { + var taprootMerkleRoot [32]byte + taprootMerkleRoot[0] = 0xab + taprootMerkleRoot[31] = 0xcd + + payload, err := buildTaggedTBTCSignerStartSignRoundRequestPayload( + "session-1", + 3, + []byte{0xab, 0xcd}, + "key-group-1", + []uint16{1, 2, 3}, + &taprootMerkleRoot, + ) + if err != nil { + t.Fatalf("unexpected payload build error: [%v]", err) + } + + var request buildTaggedTBTCSignerStartSignRoundRequest + if err := json.Unmarshal(payload, &request); err != nil { + t.Fatalf("cannot decode request payload: [%v]", err) + } + + if request.TaprootMerkleRootHex == nil { + t.Fatal("expected taproot merkle root") + } + + expectedTaprootMerkleRootHex := hex.EncodeToString(taprootMerkleRoot[:]) + if *request.TaprootMerkleRootHex != expectedTaprootMerkleRootHex { + t.Fatalf( + "unexpected taproot merkle root\nexpected: [%v]\nactual: [%v]", + expectedTaprootMerkleRootHex, + *request.TaprootMerkleRootHex, + ) + } +} + func TestBuildTaggedTBTCSignerStartSignRoundRequestPayload_EmptySessionID(t *testing.T) { _, err := buildTaggedTBTCSignerStartSignRoundRequestPayload( "", @@ -464,6 +543,7 @@ func TestBuildTaggedTBTCSignerStartSignRoundRequestPayload_EmptySessionID(t *tes []byte{0xab}, "key-group-1", nil, + nil, ) if !errors.Is(err, ErrNativeBridgeOperationFailed) { t.Fatalf( @@ -488,6 +568,7 @@ func TestBuildTaggedTBTCSignerStartSignRoundRequestPayload_ZeroMemberID(t *testi []byte{0xab}, "key-group-1", nil, + nil, ) if !errors.Is(err, ErrNativeBridgeOperationFailed) { t.Fatalf( @@ -514,6 +595,7 @@ func TestBuildTaggedTBTCSignerFinalizeSignRoundRequestPayload(t *testing.T) { Data: []byte{0xde, 0xad}, }, }, + nil, ) if err != nil { t.Fatalf("unexpected payload build error: [%v]", err) @@ -557,6 +639,46 @@ func TestBuildTaggedTBTCSignerFinalizeSignRoundRequestPayload(t *testing.T) { } } +func TestBuildTaggedTBTCSignerFinalizeSignRoundRequestPayload_TaprootMerkleRoot( + t *testing.T, +) { + var taprootMerkleRoot [32]byte + taprootMerkleRoot[0] = 0xab + taprootMerkleRoot[31] = 0xcd + + payload, err := buildTaggedTBTCSignerFinalizeSignRoundRequestPayload( + "session-1", + []NativeTBTCSignerRoundContribution{ + { + Identifier: 7, + Data: []byte{0xde, 0xad}, + }, + }, + &taprootMerkleRoot, + ) + if err != nil { + t.Fatalf("unexpected payload build error: [%v]", err) + } + + var request buildTaggedTBTCSignerFinalizeSignRoundRequest + if err := json.Unmarshal(payload, &request); err != nil { + t.Fatalf("cannot decode request payload: [%v]", err) + } + + if request.TaprootMerkleRootHex == nil { + t.Fatal("expected taproot merkle root") + } + + expectedTaprootMerkleRootHex := hex.EncodeToString(taprootMerkleRoot[:]) + if *request.TaprootMerkleRootHex != expectedTaprootMerkleRootHex { + t.Fatalf( + "unexpected taproot merkle root\nexpected: [%v]\nactual: [%v]", + expectedTaprootMerkleRootHex, + *request.TaprootMerkleRootHex, + ) + } +} + func TestDecodeBuildTaggedTBTCSignerStartSignRoundResponse(t *testing.T) { roundState, err := decodeBuildTaggedTBTCSignerStartSignRoundResponse( []byte( diff --git a/pkg/frost/signing/native_frost_protocol_frost_native.go b/pkg/frost/signing/native_frost_protocol_frost_native.go index e97b00dd99..722f4ce5af 100644 --- a/pkg/frost/signing/native_frost_protocol_frost_native.go +++ b/pkg/frost/signing/native_frost_protocol_frost_native.go @@ -13,6 +13,7 @@ import ( "github.com/btcsuite/btcd/btcec/v2/schnorr" "github.com/ipfs/go-log/v2" + "github.com/keep-network/keep-core/pkg/bitcoin" "github.com/keep-network/keep-core/pkg/frost" "github.com/keep-network/keep-core/pkg/frost/roast/attempt" "github.com/keep-network/keep-core/pkg/net" @@ -411,11 +412,28 @@ func executeNativeFROSTSigning( return nil, fmt.Errorf("native FROST signing package is nil") } - ownSignatureShare, err := engine.Sign( - signingPackage, - ownNonces, - signerMaterial.KeyPackage, - ) + var ownSignatureShare *NativeFROSTSignatureShare + if request.TaprootMerkleRoot != nil { + tweakedEngine, ok := engine.(NativeFROSTTaprootTweakedSigningEngine) + if !ok { + return nil, fmt.Errorf( + "native FROST engine does not support taproot tweaked signing", + ) + } + + ownSignatureShare, err = tweakedEngine.SignWithTaprootTweak( + signingPackage, + ownNonces, + signerMaterial.KeyPackage, + request.TaprootMerkleRoot[:], + ) + } else { + ownSignatureShare, err = engine.Sign( + signingPackage, + ownNonces, + signerMaterial.KeyPackage, + ) + } if err != nil { return nil, fmt.Errorf("native FROST round two signing failed: [%w]", err) } @@ -482,11 +500,28 @@ func executeNativeFROSTSigning( ) } - signatureBytes, err := engine.Aggregate( - signingPackage, - orderedSignatureShares, - signerMaterial.PublicKeyPackage, - ) + var signatureBytes []byte + if request.TaprootMerkleRoot != nil { + tweakedEngine, ok := engine.(NativeFROSTTaprootTweakedSigningEngine) + if !ok { + return nil, fmt.Errorf( + "native FROST engine does not support taproot tweaked aggregation", + ) + } + + signatureBytes, err = tweakedEngine.AggregateWithTaprootTweak( + signingPackage, + orderedSignatureShares, + signerMaterial.PublicKeyPackage, + request.TaprootMerkleRoot[:], + ) + } else { + signatureBytes, err = engine.Aggregate( + signingPackage, + orderedSignatureShares, + signerMaterial.PublicKeyPackage, + ) + } if err != nil { return nil, fmt.Errorf("native FROST aggregation failed: [%w]", err) } @@ -502,6 +537,7 @@ func executeNativeFROSTSigning( signature, messageDigest, signerMaterial.PublicKeyPackage, + request.TaprootMerkleRoot, ); err != nil { return nil, fmt.Errorf( "native FROST aggregation returned non-verifiable BIP-340 signature: [%w]", @@ -524,6 +560,7 @@ func verifyNativeFROSTBIP340Signature( signature *frost.Signature, messageDigest [attempt.MessageDigestLength]byte, publicKeyPackage *NativeFROSTPublicKeyPackage, + taprootMerkleRoot *[32]byte, ) error { if signature == nil { return fmt.Errorf("signature is nil") @@ -545,6 +582,21 @@ func verifyNativeFROSTBIP340Signature( ) } + if taprootMerkleRoot != nil { + var internalKey [32]byte + copy(internalKey[:], publicKeyBytes) + + outputKey, err := bitcoin.TaprootOutputKey( + internalKey, + taprootMerkleRoot, + ) + if err != nil { + return fmt.Errorf("cannot derive taproot output key: [%w]", err) + } + + publicKeyBytes = outputKey[:] + } + publicKey, err := schnorr.ParsePubKey(publicKeyBytes) if err != nil { return fmt.Errorf("cannot parse BIP-340 verifying key: [%w]", err) diff --git a/pkg/frost/signing/native_frost_protocol_frost_native_test.go b/pkg/frost/signing/native_frost_protocol_frost_native_test.go index cc2f1d3f62..635595cff7 100644 --- a/pkg/frost/signing/native_frost_protocol_frost_native_test.go +++ b/pkg/frost/signing/native_frost_protocol_frost_native_test.go @@ -344,6 +344,7 @@ func TestVerifyNativeFROSTBIP340SignatureRejectsInvalidAggregate( &NativeFROSTPublicKeyPackage{ VerifyingKey: deterministicNativeFROSTSigningVerifyingKeyForTest(), }, + nil, ) if err == nil { t.Fatal("expected invalid BIP-340 aggregate signature to be rejected") diff --git a/pkg/frost/signing/native_tbtc_signer_engine_frost_native.go b/pkg/frost/signing/native_tbtc_signer_engine_frost_native.go index b19c88bf63..cfecec5c53 100644 --- a/pkg/frost/signing/native_tbtc_signer_engine_frost_native.go +++ b/pkg/frost/signing/native_tbtc_signer_engine_frost_native.go @@ -4,13 +4,6 @@ package signing import "fmt" -// NativeTBTCSignerDKGParticipant identifies a DKG participant for coarse -// tbtc-signer RunDKG operation. -type NativeTBTCSignerDKGParticipant struct { - Identifier uint16 `json:"identifier"` - PublicKeyHex string `json:"publicKeyHex"` -} - // NativeTBTCSignerDKGResult captures DKG result metadata returned by RunDKG. type NativeTBTCSignerDKGResult struct { SessionID string `json:"sessionID"` @@ -74,10 +67,12 @@ type NativeTBTCSignerEngine interface { message []byte, keyGroup string, signingParticipants []uint16, + taprootMerkleRoot *[32]byte, ) (*NativeTBTCSignerRoundState, error) FinalizeSignRound( sessionID string, roundContributions []NativeTBTCSignerRoundContribution, + taprootMerkleRoot *[32]byte, ) ([]byte, error) BuildTaprootTx( sessionID string, @@ -87,6 +82,18 @@ type NativeTBTCSignerEngine interface { ) (*NativeTBTCSignerTxResult, error) } +// NativeTBTCSignerSeededDKGEngine is implemented by tbtc-signer engines that +// can pin development dealer DKG to an externally supplied seed. Production +// distributed DKG does not rely on this helper. +type NativeTBTCSignerSeededDKGEngine interface { + RunDKGWithSeed( + sessionID string, + participants []NativeTBTCSignerDKGParticipant, + threshold uint16, + dkgSeedHex string, + ) (*NativeTBTCSignerDKGResult, error) +} + var nativeTBTCSignerEngine NativeTBTCSignerEngine // RegisterNativeTBTCSignerEngine registers the coarse tbtc-signer engine used @@ -113,6 +120,12 @@ func UnregisterNativeTBTCSignerEngine() { nativeTBTCSignerEngine = nil } +// CurrentNativeTBTCSignerEngine returns the registered coarse tbtc-signer +// engine. +func CurrentNativeTBTCSignerEngine() NativeTBTCSignerEngine { + return currentNativeTBTCSignerEngine() +} + func currentNativeTBTCSignerEngine() NativeTBTCSignerEngine { executionBackendMutex.RLock() defer executionBackendMutex.RUnlock() diff --git a/pkg/frost/signing/native_tbtc_signer_engine_frost_native_test.go b/pkg/frost/signing/native_tbtc_signer_engine_frost_native_test.go index a0487c6f75..06850fd530 100644 --- a/pkg/frost/signing/native_tbtc_signer_engine_frost_native_test.go +++ b/pkg/frost/signing/native_tbtc_signer_engine_frost_native_test.go @@ -23,16 +23,20 @@ func (mntse *mockNativeTBTCSignerEngine) StartSignRound( message []byte, keyGroup string, signingParticipants []uint16, + taprootMerkleRoot *[32]byte, ) (*NativeTBTCSignerRoundState, error) { _ = memberIdentifier _ = signingParticipants + _ = taprootMerkleRoot return nil, fmt.Errorf("not implemented") } func (mntse *mockNativeTBTCSignerEngine) FinalizeSignRound( sessionID string, roundContributions []NativeTBTCSignerRoundContribution, + taprootMerkleRoot *[32]byte, ) ([]byte, error) { + _ = taprootMerkleRoot return nil, fmt.Errorf("not implemented") } diff --git a/pkg/frost/signing/native_tbtc_signer_material.go b/pkg/frost/signing/native_tbtc_signer_material.go index 3b5391e391..6e0f458630 100644 --- a/pkg/frost/signing/native_tbtc_signer_material.go +++ b/pkg/frost/signing/native_tbtc_signer_material.go @@ -15,6 +15,9 @@ const ( // run, and is refused by default at signing time. See // `AcceptScaffoldKeyGroupEnvVar` for the opt-in escape hatch. NativeTBTCSignerKeyGroupSourceLegacyWalletPubKey = "legacy-wallet-pubkey" + // NativeTBTCSignerKeyGroupSourceDKGPersisted marks key-group material + // produced by a FROST wallet DKG and persisted for later signing. + NativeTBTCSignerKeyGroupSourceDKGPersisted = "dkg-persisted" // AcceptScaffoldKeyGroupEnvVar is the operator-facing opt-in that allows // the FROST tbtc-signer FFI path to accept signer material whose @@ -27,9 +30,20 @@ const ( // NativeTBTCSignerMaterialPayload is the signer-material payload schema for // `frost-tbtc-signer-v1`. type NativeTBTCSignerMaterialPayload struct { - KeyGroup string `json:"keyGroup"` - KeyGroupSource string `json:"keyGroupSource,omitempty"` - LegacyPrivateKeyShareHex string `json:"legacyPrivateKeyShareHex,omitempty"` + KeyGroup string `json:"keyGroup"` + TaprootOutputKey string `json:"taprootOutputKey,omitempty"` + KeyGroupSource string `json:"keyGroupSource,omitempty"` + DKGSeedHex string `json:"dkgSeedHex,omitempty"` + DKGParticipants []NativeTBTCSignerDKGParticipant `json:"dkgParticipants,omitempty"` + DKGThreshold uint16 `json:"dkgThreshold,omitempty"` + LegacyPrivateKeyShareHex string `json:"legacyPrivateKeyShareHex,omitempty"` +} + +// NativeTBTCSignerDKGParticipant identifies a DKG participant for coarse +// tbtc-signer RunDKG operation. +type NativeTBTCSignerDKGParticipant struct { + Identifier uint16 `json:"identifier"` + PublicKeyHex string `json:"publicKeyHex"` } // AcceptScaffoldKeyGroupEnabled reports whether the operator has opted into diff --git a/pkg/frost/signing/request.go b/pkg/frost/signing/request.go index e14b4da13c..a9782593d5 100644 --- a/pkg/frost/signing/request.go +++ b/pkg/frost/signing/request.go @@ -19,7 +19,10 @@ type Request struct { SignerMaterial any // PrivateKeyShare is a deprecated legacy alias kept for backward // compatibility while migrating to backend-specific signer material. - PrivateKeyShare *tecdsa.PrivateKeyShare + PrivateKeyShare *tecdsa.PrivateKeyShare + // TaprootMerkleRoot carries the optional BIP-341 script merkle root used + // to tweak a Taproot key-path signature. + TaprootMerkleRoot *[32]byte GroupSize int DishonestThreshold int Channel net.BroadcastChannel diff --git a/pkg/maintainer/spv/bitcoin_chain_test.go b/pkg/maintainer/spv/bitcoin_chain_test.go index 2f790bf11f..447c2ca005 100644 --- a/pkg/maintainer/spv/bitcoin_chain_test.go +++ b/pkg/maintainer/spv/bitcoin_chain_test.go @@ -148,6 +148,38 @@ func (lbc *localBitcoinChain) GetTransactionsForPublicKeyHash( return matchingTransactions, nil } +func (lbc *localBitcoinChain) GetTransactionsForPublicKeyScripts( + publicKeyScripts []bitcoin.Script, + limit int, +) ([]*bitcoin.Transaction, error) { + lbc.mutex.Lock() + defer lbc.mutex.Unlock() + + matchingTransactions := make([]*bitcoin.Transaction, 0) + + for _, transaction := range lbc.transactions { + transactionMatches := false + for _, output := range transaction.Outputs { + for _, publicKeyScript := range publicKeyScripts { + if bytes.Equal(output.PublicKeyScript, publicKeyScript) { + matchingTransactions = append(matchingTransactions, transaction) + transactionMatches = true + break + } + } + if transactionMatches { + break + } + } + } + + if len(matchingTransactions) > limit { + return matchingTransactions[len(matchingTransactions)-limit:], nil + } + + return matchingTransactions, nil +} + func (lbc *localBitcoinChain) GetTxHashesForPublicKeyHash( publicKeyHash [20]byte, ) ([]bitcoin.Hash, error) { diff --git a/pkg/maintainer/spv/chain.go b/pkg/maintainer/spv/chain.go index c9e060e9bf..a3444fd349 100644 --- a/pkg/maintainer/spv/chain.go +++ b/pkg/maintainer/spv/chain.go @@ -32,6 +32,10 @@ type Chain interface { walletPublicKeyHash [20]byte, ) (*tbtc.WalletChainData, error) + // WalletPublicKeyHashForWalletID resolves the canonical wallet ID to the + // wallet public key hash used by Bridge mappings. + WalletPublicKeyHashForWalletID(walletID [32]byte) ([20]byte, error) + // ComputeMainUtxoHash computes the hash of the provided main UTXO // according to the on-chain Bridge rules. ComputeMainUtxoHash(mainUtxo *bitcoin.UnspentTransactionOutput) [32]byte diff --git a/pkg/maintainer/spv/chain_test.go b/pkg/maintainer/spv/chain_test.go index 2a0bcc0a89..99cb4b4013 100644 --- a/pkg/maintainer/spv/chain_test.go +++ b/pkg/maintainer/spv/chain_test.go @@ -163,6 +163,28 @@ func (lc *localChain) GetWallet(walletPublicKeyHash [20]byte) ( return walletChainData, nil } +func (lc *localChain) WalletPublicKeyHashForWalletID( + walletID [32]byte, +) ([20]byte, error) { + lc.mutex.Lock() + defer lc.mutex.Unlock() + + for walletPublicKeyHash, walletChainData := range lc.wallets { + if walletChainData.WalletID == walletID || + walletChainData.EcdsaWalletID == walletID { + return walletPublicKeyHash, nil + } + } + + legacyWalletPublicKeyHash, ok := + tbtc.WalletPublicKeyHashFromLegacyWalletID(walletID) + if ok { + return legacyWalletPublicKeyHash, nil + } + + return [20]byte{}, fmt.Errorf("no wallet for given wallet ID") +} + func (lc *localChain) setWallet( walletPublicKeyHash [20]byte, walletChainData *tbtc.WalletChainData, diff --git a/pkg/maintainer/spv/deposit_sweep.go b/pkg/maintainer/spv/deposit_sweep.go index 2b0b8a5f77..4e1d52eb8f 100644 --- a/pkg/maintainer/spv/deposit_sweep.go +++ b/pkg/maintainer/spv/deposit_sweep.go @@ -6,7 +6,6 @@ import ( "github.com/keep-network/keep-core/pkg/tbtc" - "github.com/btcsuite/btcd/txscript" "github.com/ethereum/go-ethereum/common" "github.com/keep-network/keep-core/pkg/bitcoin" "github.com/keep-network/keep-core/pkg/chain" @@ -156,13 +155,25 @@ func parseDepositSweepTransactionInputs( publicKeyScript := previousTransaction.Outputs[outpointIndex].PublicKeyScript value := previousTransaction.Outputs[outpointIndex].Value - scriptClass := txscript.GetScriptClass(publicKeyScript) + scriptType := bitcoin.GetScriptType(publicKeyScript) - if scriptClass == txscript.PubKeyHashTy || - scriptClass == txscript.WitnessV0PubKeyHashTy { - // The input is P2PKH or P2WPKH, so we found main UTXO. There should - // be at most one main UTXO. If any input of this kind has already - // been found, report an error. + deposit, found, err := spvChain.GetDepositRequest( + outpointTransactionHash, + outpointIndex, + ) + if err != nil { + return bitcoin.UnspentTransactionOutput{}, common.Address{}, fmt.Errorf( + "failed to get deposit request: [%v]", + err, + ) + } + + if !found && (scriptType == bitcoin.P2PKHScript || + scriptType == bitcoin.P2WPKHScript || + scriptType == bitcoin.P2TRScript) { + // The input is a direct wallet UTXO, so we found main UTXO. + // There should be at most one main UTXO. If any input of this + // kind has already been found, report an error. if mainUTXO == nil { mainUTXO = &bitcoin.UnspentTransactionOutput{ Outpoint: &bitcoin.TransactionOutpoint{ @@ -177,31 +188,13 @@ func parseDepositSweepTransactionInputs( "inputs", ) } - } else if scriptClass == txscript.ScriptHashTy || - scriptClass == txscript.WitnessV0ScriptHashTy { - // The input is P2SH or P2WSH, so we found a deposit input. All + } else if found && (scriptType == bitcoin.P2SHScript || + scriptType == bitcoin.P2WSHScript || + scriptType == bitcoin.P2TRScript) { + // The input is a deposit input. All // the deposits should have the same vault set or no vault at all. // If the vault if different than the vault from any previous // deposit input, report an error. - deposit, found, err := spvChain.GetDepositRequest( - outpointTransactionHash, - outpointIndex, - ) - if err != nil { - return bitcoin.UnspentTransactionOutput{}, common.Address{}, fmt.Errorf( - "failed to get deposit request: [%v]", - err, - ) - } - - if !found { - return bitcoin.UnspentTransactionOutput{}, common.Address{}, fmt.Errorf( - "deposit: [%v/%v] not found", - outpointTransactionHash, - outpointIndex, - ) - } - if depositAlreadyProcessed { if vault != convertVaultAddress(deposit.Vault) { return bitcoin.UnspentTransactionOutput{}, common.Address{}, fmt.Errorf( diff --git a/pkg/maintainer/spv/deposit_sweep_test.go b/pkg/maintainer/spv/deposit_sweep_test.go index dc61256ccf..69cf92736e 100644 --- a/pkg/maintainer/spv/deposit_sweep_test.go +++ b/pkg/maintainer/spv/deposit_sweep_test.go @@ -134,6 +134,193 @@ func TestSubmitDepositSweepProof(t *testing.T) { ) } +func TestParseDepositSweepTransactionInputs_TaprootDeposit(t *testing.T) { + btcChain := newLocalBitcoinChain() + spvChain := newLocalChain() + + taprootDepositScript, err := bitcoin.PayToTaproot([32]byte{0x01}) + if err != nil { + t.Fatal(err) + } + + walletScript, err := bitcoin.PayToTaproot([32]byte{0x02}) + if err != nil { + t.Fatal(err) + } + + depositTransaction := &bitcoin.Transaction{ + Version: 1, + Outputs: []*bitcoin.TransactionOutput{ + { + Value: 800000, + PublicKeyScript: taprootDepositScript, + }, + }, + } + + if err := btcChain.BroadcastTransaction(depositTransaction); err != nil { + t.Fatal(err) + } + + spvChain.setDepositRequest( + depositTransaction.Hash(), + 0, + &tbtc.DepositChainRequest{ + RevealedAt: time.Unix(1000, 0), + SweptAt: time.Unix(0, 0), + }, + ) + + depositSweepTransaction := &bitcoin.Transaction{ + Version: 1, + Inputs: []*bitcoin.TransactionInput{ + { + Outpoint: &bitcoin.TransactionOutpoint{ + TransactionHash: depositTransaction.Hash(), + OutputIndex: 0, + }, + Witness: [][]byte{make([]byte, 64)}, + Sequence: 0xffffffff, + }, + }, + Outputs: []*bitcoin.TransactionOutput{ + { + Value: 799000, + PublicKeyScript: walletScript, + }, + }, + } + + mainUTXO, vault, err := parseDepositSweepTransactionInputs( + btcChain, + spvChain, + depositSweepTransaction, + ) + if err != nil { + t.Fatal(err) + } + + expectedMainUtxo := bitcoin.UnspentTransactionOutput{ + Outpoint: &bitcoin.TransactionOutpoint{ + TransactionHash: bitcoin.Hash{}, + OutputIndex: 0, + }, + Value: 0, + } + if diff := deep.Equal(expectedMainUtxo, mainUTXO); diff != nil { + t.Errorf("invalid main UTXO: %v", diff) + } + + expectedVault := [20]byte{} + testutils.AssertBytesEqual(t, expectedVault[:], vault[:]) +} + +func TestParseDepositSweepTransactionInputs_TaprootMainUtxoAndDeposit( + t *testing.T, +) { + btcChain := newLocalBitcoinChain() + spvChain := newLocalChain() + + walletScript, err := bitcoin.PayToTaproot([32]byte{0x01}) + if err != nil { + t.Fatal(err) + } + + taprootDepositScript, err := bitcoin.PayToTaproot([32]byte{0x02}) + if err != nil { + t.Fatal(err) + } + + mainUtxoTransaction := &bitcoin.Transaction{ + Version: 1, + Outputs: []*bitcoin.TransactionOutput{ + { + Value: 700000, + PublicKeyScript: walletScript, + }, + }, + } + + depositTransaction := &bitcoin.Transaction{ + Version: 2, + Outputs: []*bitcoin.TransactionOutput{ + { + Value: 800000, + PublicKeyScript: taprootDepositScript, + }, + }, + } + + for _, transaction := range []*bitcoin.Transaction{ + mainUtxoTransaction, + depositTransaction, + } { + if err := btcChain.BroadcastTransaction(transaction); err != nil { + t.Fatal(err) + } + } + + spvChain.setDepositRequest( + depositTransaction.Hash(), + 0, + &tbtc.DepositChainRequest{ + RevealedAt: time.Unix(1000, 0), + SweptAt: time.Unix(0, 0), + }, + ) + + depositSweepTransaction := &bitcoin.Transaction{ + Version: 1, + Inputs: []*bitcoin.TransactionInput{ + { + Outpoint: &bitcoin.TransactionOutpoint{ + TransactionHash: mainUtxoTransaction.Hash(), + OutputIndex: 0, + }, + Witness: [][]byte{make([]byte, 64)}, + Sequence: 0xffffffff, + }, + { + Outpoint: &bitcoin.TransactionOutpoint{ + TransactionHash: depositTransaction.Hash(), + OutputIndex: 0, + }, + Witness: [][]byte{make([]byte, 64)}, + Sequence: 0xffffffff, + }, + }, + Outputs: []*bitcoin.TransactionOutput{ + { + Value: 1499000, + PublicKeyScript: walletScript, + }, + }, + } + + mainUTXO, vault, err := parseDepositSweepTransactionInputs( + btcChain, + spvChain, + depositSweepTransaction, + ) + if err != nil { + t.Fatal(err) + } + + expectedMainUtxo := bitcoin.UnspentTransactionOutput{ + Outpoint: &bitcoin.TransactionOutpoint{ + TransactionHash: mainUtxoTransaction.Hash(), + OutputIndex: 0, + }, + Value: 700000, + } + if diff := deep.Equal(expectedMainUtxo, mainUTXO); diff != nil { + t.Errorf("invalid main UTXO: %v", diff) + } + + expectedVault := [20]byte{} + testutils.AssertBytesEqual(t, expectedVault[:], vault[:]) +} + func TestGetUnprovenDepositSweepTransactions(t *testing.T) { bytesFromHex := func(str string) []byte { value, err := hex.DecodeString(str) diff --git a/pkg/maintainer/spv/redemptions.go b/pkg/maintainer/spv/redemptions.go index e504860f81..4694d7665b 100644 --- a/pkg/maintainer/spv/redemptions.go +++ b/pkg/maintainer/spv/redemptions.go @@ -75,6 +75,7 @@ func submitRedemptionProof( } mainUTXO, walletPublicKeyHash, err := parseRedemptionTransactionInput( + spvChain, btcChain, transaction, ) @@ -114,6 +115,7 @@ func submitRedemptionProof( // parseRedemptionTransactionInput parses the transaction's input and // returns the main UTXO and the wallet public key hash. func parseRedemptionTransactionInput( + spvChain Chain, btcChain bitcoin.Chain, transaction *bitcoin.Transaction, ) (bitcoin.UnspentTransactionOutput, [20]byte, error) { @@ -146,18 +148,127 @@ func parseRedemptionTransactionInput( Value: spentOutput.Value, } - // Extract the wallet public key hash from script - walletPublicKeyHash, err := bitcoin.ExtractPublicKeyHash(spentOutput.PublicKeyScript) + walletPublicKeyHash, err := walletPublicKeyHashFromScript( + spvChain, + spentOutput.PublicKeyScript, + ) if err != nil { - return bitcoin.UnspentTransactionOutput{}, [20]byte{}, fmt.Errorf( - "cannot extract wallet public key hash: [%v]", - err, - ) + return bitcoin.UnspentTransactionOutput{}, [20]byte{}, err } return mainUtxo, walletPublicKeyHash, nil } +func walletPublicKeyHashFromScript( + spvChain Chain, + script bitcoin.Script, +) ([20]byte, error) { + switch bitcoin.GetScriptType(script) { + case bitcoin.P2PKHScript, bitcoin.P2WPKHScript: + walletPublicKeyHash, err := bitcoin.ExtractPublicKeyHash(script) + if err != nil { + return [20]byte{}, fmt.Errorf( + "cannot extract wallet public key hash: [%v]", + err, + ) + } + + return walletPublicKeyHash, nil + case bitcoin.P2TRScript: + walletID, err := bitcoin.ExtractTaprootKey(script) + if err != nil { + return [20]byte{}, fmt.Errorf( + "cannot extract wallet Taproot key: [%v]", + err, + ) + } + + walletPublicKeyHash, err := + spvChain.WalletPublicKeyHashForWalletID(walletID) + if err != nil { + return [20]byte{}, fmt.Errorf( + "cannot resolve wallet public key hash for Taproot wallet ID "+ + "[0x%x]: [%v]", + walletID, + err, + ) + } + + return walletPublicKeyHash, nil + default: + return [20]byte{}, fmt.Errorf( + "not a wallet public key hash or Taproot script", + ) + } +} + +type transactionsForPublicKeyScriptsChain interface { + GetTransactionsForPublicKeyScripts( + publicKeyScripts []bitcoin.Script, + limit int, + ) ([]*bitcoin.Transaction, error) +} + +func getWalletTransactions( + walletPublicKeyHash [20]byte, + wallet *tbtc.WalletChainData, + transactionLimit int, + btcChain bitcoin.Chain, +) ([]*bitcoin.Transaction, error) { + scriptChain, ok := btcChain.(transactionsForPublicKeyScriptsChain) + if !ok { + return btcChain.GetTransactionsForPublicKeyHash( + walletPublicKeyHash, + transactionLimit, + ) + } + + publicKeyScripts, err := walletPublicKeyScripts( + walletPublicKeyHash, + wallet, + ) + if err != nil { + return nil, err + } + + return scriptChain.GetTransactionsForPublicKeyScripts( + publicKeyScripts, + transactionLimit, + ) +} + +func walletPublicKeyScripts( + walletPublicKeyHash [20]byte, + wallet *tbtc.WalletChainData, +) ([]bitcoin.Script, error) { + p2pkh, err := bitcoin.PayToPublicKeyHash(walletPublicKeyHash) + if err != nil { + return nil, fmt.Errorf("cannot construct P2PKH for wallet: [%v]", err) + } + + p2wpkh, err := bitcoin.PayToWitnessPublicKeyHash(walletPublicKeyHash) + if err != nil { + return nil, fmt.Errorf("cannot construct P2WPKH for wallet: [%v]", err) + } + + publicKeyScripts := []bitcoin.Script{p2pkh, p2wpkh} + + if wallet.WalletID != [32]byte{} { + // FROST Taproot wallets use the canonical wallet ID as the x-only + // Taproot output key. Legacy wallets will not normally have history + // under this script, but querying it is harmless and keeps discovery + // independent of wallet generation. + p2tr, err := bitcoin.PayToTaproot(wallet.WalletID) + if err != nil { + return nil, fmt.Errorf("cannot construct P2TR for wallet: [%v]", err) + } + + publicKeyScripts = append(publicKeyScripts, p2tr) + } + + return publicKeyScripts, nil +} + func getUnprovenRedemptionTransactions( historyDepth uint64, transactionLimit int, @@ -221,9 +332,11 @@ func getUnprovenRedemptionTransactions( continue } - walletTransactions, err := btcChain.GetTransactionsForPublicKeyHash( + walletTransactions, err := getWalletTransactions( walletPublicKeyHash, + wallet, transactionLimit, + btcChain, ) if err != nil { return nil, fmt.Errorf( @@ -305,7 +418,11 @@ func isUnprovenRedemptionTransaction( // First, check if the given output is a change (if it wasn't // found yet). if !changeFound { - isChange, err := isWalletChangeOutput(walletPublicKeyHash, output) + isChange, err := isWalletChangeOutput( + walletPublicKeyHash, + spvChain, + output, + ) if err != nil { return false, fmt.Errorf( "failed to check if output is wallet change: [%v]", @@ -351,6 +468,7 @@ func isUnprovenRedemptionTransaction( func isWalletChangeOutput( walletPublicKeyHash [20]byte, + spvChain Chain, output *bitcoin.TransactionOutput, ) (bool, error) { walletP2PKH, err := bitcoin.PayToPublicKeyHash(walletPublicKeyHash) @@ -363,5 +481,26 @@ func isWalletChangeOutput( } script := output.PublicKeyScript - return bytes.Equal(script, walletP2PKH) || bytes.Equal(script, walletP2WPKH), nil + if bytes.Equal(script, walletP2PKH) || bytes.Equal(script, walletP2WPKH) { + return true, nil + } + + if bitcoin.GetScriptType(script) != bitcoin.P2TRScript { + return false, nil + } + + wallet, err := spvChain.GetWallet(walletPublicKeyHash) + if err != nil { + return false, fmt.Errorf("cannot get wallet: [%v]", err) + } + if wallet.WalletID == [32]byte{} { + return false, nil + } + + walletP2TR, err := bitcoin.PayToTaproot(wallet.WalletID) + if err != nil { + return false, fmt.Errorf("cannot construct P2TR for wallet: [%v]", err) + } + + return bytes.Equal(script, walletP2TR), nil } diff --git a/pkg/maintainer/spv/redemptions_test.go b/pkg/maintainer/spv/redemptions_test.go index 4f10a3a208..f019a7c9de 100644 --- a/pkg/maintainer/spv/redemptions_test.go +++ b/pkg/maintainer/spv/redemptions_test.go @@ -112,6 +112,140 @@ func TestSubmitRedemptionProof(t *testing.T) { testutils.AssertBytesEqual(t, bytesFromHex("03b74d6893ad46dfdd01b9e0e3b3385f4fce2d1e"), submittedProof.walletPublicKeyHash[:]) } +func TestSubmitRedemptionProof_TaprootMainUtxo(t *testing.T) { + bytesFromHex := func(str string) []byte { + value, err := hex.DecodeString(str) + if err != nil { + t.Fatal(err) + } + + return value + } + + bytes20FromHex := func(str string) [20]byte { + var value [20]byte + copy(value[:], bytesFromHex(str)) + return value + } + + bytes32FromHex := func(str string) [32]byte { + var value [32]byte + copy(value[:], bytesFromHex(str)) + return value + } + + requiredConfirmations := uint(6) + + btcChain := newLocalBitcoinChain() + spvChain := newLocalChain() + + walletPublicKeyHash := bytes20FromHex( + "2a621226d6f9916a929c0ab8cc7d3252c1485708", + ) + walletID := bytes32FromHex( + "93fd799256287638b1589bc4c8db1b11fcf873796aabeac9edf4cf238f38e596", + ) + walletP2TR, err := bitcoin.PayToTaproot(walletID) + if err != nil { + t.Fatal(err) + } + + spvChain.setWallet( + walletPublicKeyHash, + &tbtc.WalletChainData{ + WalletID: walletID, + State: tbtc.StateLive, + }, + ) + + redemptionInputTransaction := &bitcoin.Transaction{ + Version: 1, + Outputs: []*bitcoin.TransactionOutput{ + { + Value: 1000000, + PublicKeyScript: walletP2TR, + }, + }, + } + redemptionTransaction := &bitcoin.Transaction{ + Version: 1, + Inputs: []*bitcoin.TransactionInput{ + { + Outpoint: &bitcoin.TransactionOutpoint{ + TransactionHash: redemptionInputTransaction.Hash(), + OutputIndex: 0, + }, + Sequence: 0xffffffff, + }, + }, + Outputs: []*bitcoin.TransactionOutput{ + { + Value: 900000, + PublicKeyScript: bitcoin.Script{0x00, 0x14, 0x01}, + }, + }, + } + + for _, transaction := range []*bitcoin.Transaction{ + redemptionInputTransaction, + redemptionTransaction, + } { + if err := btcChain.BroadcastTransaction(transaction); err != nil { + t.Fatal(err) + } + } + + proof := &bitcoin.SpvProof{ + MerkleProof: []byte{0x01}, + TxIndexInBlock: 2, + BitcoinHeaders: []byte{0x03}, + } + + mockSpvProofAssembler := func( + hash bitcoin.Hash, + confirmations uint, + btcChain bitcoin.Chain, + ) (*bitcoin.Transaction, *bitcoin.SpvProof, error) { + if hash == redemptionTransaction.Hash() && confirmations == requiredConfirmations { + return redemptionTransaction, proof, nil + } + + return nil, nil, fmt.Errorf("error while assembling spv proof") + } + + err = submitRedemptionProof( + redemptionTransaction.Hash(), + requiredConfirmations, + btcChain, + spvChain, + mockSpvProofAssembler, + getGlobalMetricsRecorder(), + ) + if err != nil { + t.Fatal(err) + } + + submittedProofs := spvChain.getSubmittedRedemptionProofs() + testutils.AssertIntsEqual(t, "proofs count", 1, len(submittedProofs)) + + expectedMainUtxo := bitcoin.UnspentTransactionOutput{ + Outpoint: &bitcoin.TransactionOutpoint{ + TransactionHash: redemptionInputTransaction.Hash(), + OutputIndex: 0, + }, + Value: 1000000, + } + if diff := deep.Equal(expectedMainUtxo, submittedProofs[0].mainUTXO); diff != nil { + t.Errorf("invalid main UTXO: %v", diff) + } + + testutils.AssertBytesEqual( + t, + walletPublicKeyHash[:], + submittedProofs[0].walletPublicKeyHash[:], + ) +} + func TestGetUnprovenRedemptionTransactions(t *testing.T) { bytesFromHex := func(str string) []byte { value, err := hex.DecodeString(str) @@ -312,3 +446,149 @@ func TestGetUnprovenRedemptionTransactions(t *testing.T) { t.Errorf("invalid unproven transaction hashes: %v", diff) } } + +func TestGetUnprovenRedemptionTransactions_TaprootWallet(t *testing.T) { + bytesFromHex := func(str string) []byte { + value, err := hex.DecodeString(str) + if err != nil { + t.Fatal(err) + } + + return value + } + + bytes20FromHex := func(str string) [20]byte { + var value [20]byte + copy(value[:], bytesFromHex(str)) + return value + } + + bytes32FromHex := func(str string) [32]byte { + var value [32]byte + copy(value[:], bytesFromHex(str)) + return value + } + + historyDepth := uint64(5) + transactionLimit := 10 + + btcChain := newLocalBitcoinChain() + spvChain := newLocalChain() + + currentBlock := uint64(1000) + blockCounter := newMockBlockCounter() + blockCounter.SetCurrentBlock(currentBlock) + spvChain.setBlockCounter(blockCounter) + + walletPublicKeyHash := bytes20FromHex( + "2a621226d6f9916a929c0ab8cc7d3252c1485708", + ) + walletID := bytes32FromHex( + "93fd799256287638b1589bc4c8db1b11fcf873796aabeac9edf4cf238f38e596", + ) + walletP2TR, err := bitcoin.PayToTaproot(walletID) + if err != nil { + t.Fatal(err) + } + redeemerScript, err := bitcoin.PayToWitnessPublicKeyHash( + bytes20FromHex("e3395778bb7f567e5a527ced184320018e59b4de"), + ) + if err != nil { + t.Fatal(err) + } + + mainUtxoTransaction := &bitcoin.Transaction{ + Version: 1, + Outputs: []*bitcoin.TransactionOutput{ + { + Value: 1000000, + PublicKeyScript: walletP2TR, + }, + }, + } + redemptionTransaction := &bitcoin.Transaction{ + Version: 1, + Inputs: []*bitcoin.TransactionInput{ + { + Outpoint: &bitcoin.TransactionOutpoint{ + TransactionHash: mainUtxoTransaction.Hash(), + OutputIndex: 0, + }, + Sequence: 0xffffffff, + }, + }, + Outputs: []*bitcoin.TransactionOutput{ + { + Value: 10000, + PublicKeyScript: walletP2TR, + }, + { + Value: 900000, + PublicKeyScript: redeemerScript, + }, + }, + } + + for _, transaction := range []*bitcoin.Transaction{ + mainUtxoTransaction, + redemptionTransaction, + } { + if err := btcChain.BroadcastTransaction(transaction); err != nil { + t.Fatal(err) + } + } + + mainUtxo := &bitcoin.UnspentTransactionOutput{ + Outpoint: &bitcoin.TransactionOutpoint{ + TransactionHash: mainUtxoTransaction.Hash(), + OutputIndex: 0, + }, + Value: 1000000, + } + spvChain.setWallet( + walletPublicKeyHash, + &tbtc.WalletChainData{ + WalletID: walletID, + MainUtxoHash: spvChain.ComputeMainUtxoHash(mainUtxo), + State: tbtc.StateLive, + }, + ) + spvChain.setPendingRedemptionRequest( + walletPublicKeyHash, + &tbtc.RedemptionRequest{ + RedeemerOutputScript: redeemerScript, + }, + ) + + err = spvChain.addPastRedemptionRequestedEvent( + &tbtc.RedemptionRequestedEventFilter{ + StartBlock: currentBlock - historyDepth, + }, + &tbtc.RedemptionRequestedEvent{ + WalletPublicKeyHash: walletPublicKeyHash, + BlockNumber: 100, + }, + ) + if err != nil { + t.Fatal(err) + } + + transactions, err := getUnprovenRedemptionTransactions( + historyDepth, + transactionLimit, + btcChain, + spvChain, + ) + if err != nil { + t.Fatal(err) + } + + testutils.AssertIntsEqual(t, "transactions count", 1, len(transactions)) + if transactions[0].Hash() != redemptionTransaction.Hash() { + t.Errorf( + "invalid transaction hash\nexpected: %v\nactual: %v", + redemptionTransaction.Hash(), + transactions[0].Hash(), + ) + } +} diff --git a/pkg/tbtc/chain.go b/pkg/tbtc/chain.go index 76a016c019..bcc1e79d72 100644 --- a/pkg/tbtc/chain.go +++ b/pkg/tbtc/chain.go @@ -280,6 +280,14 @@ type BridgeChain interface { filter *DepositRevealedEventFilter, ) ([]*DepositRevealedEvent, error) + // PastTaprootDepositRevealedEvents fetches past Taproot deposit reveal + // events according to the provided filter or unfiltered if the filter is + // nil. Returned events are sorted by the block number in ascending order, + // i.e. the latest event is at the end of the slice. + PastTaprootDepositRevealedEvents( + filter *DepositRevealedEventFilter, + ) ([]*TaprootDepositRevealedEvent, error) + // GetPendingRedemptionRequest gets the on-chain pending redemption request // for the given wallet public key hash and redeemer output script. // The returned bool value indicates whether the request was found or not. @@ -397,6 +405,49 @@ func (dre *DepositRevealedEvent) GetWalletPublicKeyHash() [20]byte { return dre.WalletPublicKeyHash } +// TaprootDepositRevealedEvent represents a Taproot deposit reveal event. +// +// The Vault field is nil if the deposit does not target any vault on-chain. +type TaprootDepositRevealedEvent struct { + FundingTxHash bitcoin.Hash + FundingOutputIndex uint32 + Depositor chain.Address + Amount uint64 + BlindingFactor [8]byte + WalletPublicKeyHash [20]byte + WalletXOnlyPublicKey [32]byte + RefundPublicKeyHash [20]byte + RefundXOnlyPublicKey [32]byte + RefundLocktime [4]byte + Vault *chain.Address + BlockNumber uint64 +} + +func (tdre *TaprootDepositRevealedEvent) unpack(extraData *[32]byte) *Deposit { + return &Deposit{ + Utxo: &bitcoin.UnspentTransactionOutput{ + Outpoint: &bitcoin.TransactionOutpoint{ + TransactionHash: tdre.FundingTxHash, + OutputIndex: tdre.FundingOutputIndex, + }, + Value: int64(tdre.Amount), + }, + Depositor: tdre.Depositor, + BlindingFactor: tdre.BlindingFactor, + WalletPublicKeyHash: tdre.WalletPublicKeyHash, + WalletXOnlyPublicKey: &tdre.WalletXOnlyPublicKey, + RefundPublicKeyHash: tdre.RefundPublicKeyHash, + RefundXOnlyPublicKey: &tdre.RefundXOnlyPublicKey, + RefundLocktime: tdre.RefundLocktime, + Vault: tdre.Vault, + ExtraData: extraData, + } +} + +func (tdre *TaprootDepositRevealedEvent) GetWalletPublicKeyHash() [20]byte { + return tdre.WalletPublicKeyHash +} + // DepositRevealedEventFilter is a component allowing to filter DepositRevealedEvent. type DepositRevealedEventFilter struct { StartBlock uint64 @@ -453,6 +504,19 @@ type WalletProposalValidatorChain interface { }, ) error + // ValidateTaprootDepositSweepProposal validates the given Taproot deposit + // sweep proposal against the chain. It requires some additional data about + // the deposits that must be fetched externally. Returns an error if the + // proposal is not valid or nil otherwise. + ValidateTaprootDepositSweepProposal( + walletPublicKeyHash [20]byte, + proposal *DepositSweepProposal, + depositsExtraInfo []struct { + *Deposit + FundingTx *bitcoin.Transaction + }, + ) error + // ValidateRedemptionProposal validates the given redemption proposal // against the chain. Returns an error if the proposal is not valid or // nil otherwise. diff --git a/pkg/tbtc/chain_test.go b/pkg/tbtc/chain_test.go index e4864c4575..cd9f4d46ed 100644 --- a/pkg/tbtc/chain_test.go +++ b/pkg/tbtc/chain_test.go @@ -47,6 +47,8 @@ type movingFundsParameters = struct { } type localChain struct { + frostWalletRegistryAvailable bool + dkgResultSubmissionHandlersMutex sync.Mutex dkgResultSubmissionHandlers map[int]func(submission *DKGResultSubmittedEvent) @@ -81,6 +83,9 @@ type localChain struct { pastDepositRevealedEventsMutex sync.Mutex pastDepositRevealedEvents map[[32]byte][]*DepositRevealedEvent + pastTaprootDepositRevealedEventsMutex sync.Mutex + pastTaprootDepositRevealedEvents map[[32]byte][]*TaprootDepositRevealedEvent + pastMovingFundsCommitmentSubmittedEventsMutex sync.Mutex pastMovingFundsCommitmentSubmittedEvents map[[32]byte][]*MovingFundsCommitmentSubmittedEvent @@ -733,6 +738,42 @@ func (lc *localChain) setPastDepositRevealedEvents( return nil } +func (lc *localChain) PastTaprootDepositRevealedEvents( + filter *DepositRevealedEventFilter, +) ([]*TaprootDepositRevealedEvent, error) { + lc.pastTaprootDepositRevealedEventsMutex.Lock() + defer lc.pastTaprootDepositRevealedEventsMutex.Unlock() + + eventsKey, err := buildPastDepositRevealedEventsKey(filter) + if err != nil { + return nil, err + } + + events, ok := lc.pastTaprootDepositRevealedEvents[eventsKey] + if !ok { + return []*TaprootDepositRevealedEvent{}, nil + } + + return events, nil +} + +func (lc *localChain) setPastTaprootDepositRevealedEvents( + filter *DepositRevealedEventFilter, + events []*TaprootDepositRevealedEvent, +) error { + lc.pastTaprootDepositRevealedEventsMutex.Lock() + defer lc.pastTaprootDepositRevealedEventsMutex.Unlock() + + eventsKey, err := buildPastDepositRevealedEventsKey(filter) + if err != nil { + return err + } + + lc.pastTaprootDepositRevealedEvents[eventsKey] = events + + return nil +} + func buildPastDepositRevealedEventsKey( filter *DepositRevealedEventFilter, ) ([32]byte, error) { @@ -925,7 +966,11 @@ func (lc *localChain) IsWalletRegistered(EcdsaWalletID [32]byte) (bool, error) { } } - return false, fmt.Errorf("wallet not found") + return false, nil +} + +func (lc *localChain) FrostWalletRegistryAvailable() bool { + return lc.frostWalletRegistryAvailable } func (lc *localChain) setWallet( @@ -1036,6 +1081,21 @@ func (lc *localChain) ValidateDepositSweepProposal( return nil } +func (lc *localChain) ValidateTaprootDepositSweepProposal( + walletPublicKeyHash [20]byte, + proposal *DepositSweepProposal, + depositsExtraInfo []struct { + *Deposit + FundingTx *bitcoin.Transaction + }, +) error { + return lc.ValidateDepositSweepProposal( + walletPublicKeyHash, + proposal, + depositsExtraInfo, + ) +} + func (lc *localChain) setDepositSweepProposalValidationResult( walletPublicKeyHash [20]byte, proposal *DepositSweepProposal, @@ -1490,6 +1550,7 @@ func ConnectWithKey( blocksByTimestamp: make(map[uint64]uint64), blocksHashesByNumber: make(map[uint64][32]byte), pastDepositRevealedEvents: make(map[[32]byte][]*DepositRevealedEvent), + pastTaprootDepositRevealedEvents: make(map[[32]byte][]*TaprootDepositRevealedEvent), pastMovingFundsCommitmentSubmittedEvents: make(map[[32]byte][]*MovingFundsCommitmentSubmittedEvent), depositSweepProposalValidations: make(map[[32]byte]bool), pendingRedemptionRequests: make(map[[32]byte]*RedemptionRequest), diff --git a/pkg/tbtc/deposit.go b/pkg/tbtc/deposit.go index 361ed38eb5..7339820595 100644 --- a/pkg/tbtc/deposit.go +++ b/pkg/tbtc/deposit.go @@ -22,6 +22,17 @@ const depositScriptFormat = "14%v7508%v7576a914%v8763ac6776a914%v8804%vb175ac68" // https://github.com/keep-network/tbtc-v2/blob/4b6143974b43297e69a45191f0e2b6a25561e72b/solidity/contracts/bridge/Deposit.sol#L246 const depositWithExtraDataScriptFormat = "14%v7520%v7508%v7576a914%v8763ac6776a914%v8804%vb175ac68" +// taprootDepositRefundScriptFormat is the Taproot-native deposit refund +// tapscript format. The placeholders are: depositor, blindingFactor, +// refundLocktime, and refundXOnlyPublicKey. +const taprootDepositRefundScriptFormat = "14%v7508%v7504%vb17520%vac" + +// taprootDepositWithExtraDataRefundScriptFormat is the Taproot-native deposit +// refund tapscript format with optional 32-byte extra data. The placeholders +// are: depositor, extraData, blindingFactor, refundLocktime, and +// refundXOnlyPublicKey. +const taprootDepositWithExtraDataRefundScriptFormat = "14%v7520%v7508%v7504%vb17520%vac" + // Deposit represents a tBTC deposit. type Deposit struct { // Utxo is the unspent output of the deposit funding transaction that @@ -34,8 +45,14 @@ type Deposit struct { BlindingFactor [8]byte // WalletPublicKeyHash is a 20-byte hash of the target wallet public key. WalletPublicKeyHash [20]byte + // WalletXOnlyPublicKey is the 32-byte Taproot internal wallet key. This + // field is set for Taproot-native deposits only. + WalletXOnlyPublicKey *[32]byte // RefundPublicKeyHash is a 20-byte hash of the refund public key. RefundPublicKeyHash [20]byte + // RefundXOnlyPublicKey is the 32-byte Taproot refund key embedded in the + // refund tapscript. This field is set for Taproot-native deposits only. + RefundXOnlyPublicKey *[32]byte // RefundLocktime is a 4-byte value representing the refund locktime. RefundLocktime [4]byte // Vault is an optional field that holds the host chain address of the @@ -46,9 +63,18 @@ type Deposit struct { ExtraData *[32]byte } +// IsTaproot returns true if this deposit was revealed as Taproot-native. +func (d *Deposit) IsTaproot() bool { + return d.WalletXOnlyPublicKey != nil && d.RefundXOnlyPublicKey != nil +} + // Script constructs the deposit P2(W)SH Bitcoin script. This function // assumes the deposit's fields are correctly set. func (d *Deposit) Script() ([]byte, error) { + if d.IsTaproot() { + return nil, fmt.Errorf("Taproot deposit does not have a P2(W)SH script") + } + depositorBytes, err := hex.DecodeString( strings.TrimPrefix(d.Depositor.String(), "0x"), ) @@ -84,3 +110,54 @@ func (d *Deposit) Script() ([]byte, error) { return hex.DecodeString(script) } + +// TaprootRefundScript constructs the deposit refund tapscript. This function +// assumes the deposit's Taproot fields are correctly set. +func (d *Deposit) TaprootRefundScript() ([]byte, error) { + if !d.IsTaproot() { + return nil, fmt.Errorf("deposit is not Taproot-native") + } + + depositorBytes, err := hex.DecodeString( + strings.TrimPrefix(d.Depositor.String(), "0x"), + ) + if err != nil { + return nil, fmt.Errorf("cannot decode depositor field: [%v]", err) + } + if len(depositorBytes) != 20 { + return nil, fmt.Errorf("wrong byte length of depositor field") + } + + var script string + + if d.ExtraData != nil { + script = fmt.Sprintf( + taprootDepositWithExtraDataRefundScriptFormat, + hex.EncodeToString(depositorBytes), + hex.EncodeToString(d.ExtraData[:]), + hex.EncodeToString(d.BlindingFactor[:]), + hex.EncodeToString(d.RefundLocktime[:]), + hex.EncodeToString(d.RefundXOnlyPublicKey[:]), + ) + } else { + script = fmt.Sprintf( + taprootDepositRefundScriptFormat, + hex.EncodeToString(depositorBytes), + hex.EncodeToString(d.BlindingFactor[:]), + hex.EncodeToString(d.RefundLocktime[:]), + hex.EncodeToString(d.RefundXOnlyPublicKey[:]), + ) + } + + return hex.DecodeString(script) +} + +// TaprootMerkleRoot returns the Taproot script tree root for this deposit. +func (d *Deposit) TaprootMerkleRoot() ([32]byte, error) { + refundScript, err := d.TaprootRefundScript() + if err != nil { + return [32]byte{}, err + } + + return bitcoin.TaprootLeafHash(refundScript) +} diff --git a/pkg/tbtc/deposit_sweep.go b/pkg/tbtc/deposit_sweep.go index 824ce29d28..5702322b4e 100644 --- a/pkg/tbtc/deposit_sweep.go +++ b/pkg/tbtc/deposit_sweep.go @@ -159,8 +159,8 @@ func (dsa *depositSweepAction) execute() error { return fmt.Errorf("validate proposal step failed: [%v]", err) } - walletMainUtxo, err := DetermineWalletMainUtxo( - walletPublicKeyHash, + walletMainUtxo, err := DetermineWalletMainUtxoForPublicKey( + dsa.wallet().publicKey, dsa.chain, dsa.btcChain, ) @@ -175,8 +175,8 @@ func (dsa *depositSweepAction) execute() error { ) } - err = EnsureWalletSyncedBetweenChains( - walletPublicKeyHash, + err = EnsureWalletSyncedBetweenChainsForPublicKey( + dsa.wallet().publicKey, walletMainUtxo, dsa.chain, dsa.btcChain, @@ -288,6 +288,14 @@ func ValidateDepositSweepProposal( filter *DepositRevealedEventFilter, ) ([]*DepositRevealedEvent, error) + // PastTaprootDepositRevealedEvents fetches past Taproot deposit reveal + // events according to the provided filter or unfiltered if the filter + // is nil. Returned events are sorted by the block number in the + // ascending order, i.e. the latest event is at the end of the slice. + PastTaprootDepositRevealedEvents( + filter *DepositRevealedEventFilter, + ) ([]*TaprootDepositRevealedEvent, error) + // ValidateDepositSweepProposal validates the given deposit sweep proposal // against the chain. It requires some additional data about the deposits // that must be fetched externally. Returns an error if the proposal is @@ -301,6 +309,19 @@ func ValidateDepositSweepProposal( }, ) error + // ValidateTaprootDepositSweepProposal validates the given Taproot + // deposit sweep proposal against the chain. It requires some additional + // data about the deposits that must be fetched externally. Returns an + // error if the proposal is not valid or nil otherwise. + ValidateTaprootDepositSweepProposal( + walletPublicKeyHash [20]byte, + proposal *DepositSweepProposal, + depositsExtraInfo []struct { + *Deposit + FundingTx *bitcoin.Transaction + }, + ) error + // GetDepositRequest gets the on-chain deposit request for the given // funding transaction hash and output index.The returned values represent: // - deposit request which is non-nil only when the deposit request was @@ -331,6 +352,8 @@ func ValidateDepositSweepProposal( return nil, fmt.Errorf("proposal's reveal blocks list has a wrong length") } + taprootDepositsCount := 0 + for i, depositKey := range proposal.DepositsKeys { depositDisplayIndex := fmt.Sprintf("%v/%v", i+1, len(proposal.DepositsKeys)) @@ -377,6 +400,12 @@ func ValidateDepositSweepProposal( revealBlock := proposal.DepositsRevealBlocks[i].Uint64() + filter := &DepositRevealedEventFilter{ + StartBlock: revealBlock, + EndBlock: &revealBlock, + WalletPublicKeyHash: [][20]byte{walletPublicKeyHash}, + } + // We need to fetch the past DepositRevealed event for the given deposit. // It may be tempting to fetch such events for all deposit keys // in the proposal using a single call, however, this solution has @@ -387,11 +416,7 @@ func ValidateDepositSweepProposal( // We have the revealBlock passed by the coordinator within the proposal // so, we can use it to make a narrow call. Moreover, we use the // wallet PKH as additional filter to limit the size of returned data. - events, err := chain.PastDepositRevealedEvents(&DepositRevealedEventFilter{ - StartBlock: revealBlock, - EndBlock: &revealBlock, - WalletPublicKeyHash: [][20]byte{walletPublicKeyHash}, - }) + events, err := chain.PastDepositRevealedEvents(filter) if err != nil { return nil, fmt.Errorf( "cannot get on-chain DepositRevealed events for deposit [%v]: [%v]", @@ -411,9 +436,27 @@ func ValidateDepositSweepProposal( } } - if matchingEvent == nil { + taprootEvents, err := chain.PastTaprootDepositRevealedEvents(filter) + if err != nil { + return nil, fmt.Errorf( + "cannot get on-chain TaprootDepositRevealed events for deposit [%v]: [%v]", + depositDisplayIndex, + err, + ) + } + + var matchingTaprootEvent *TaprootDepositRevealedEvent + for _, event := range taprootEvents { + if event.FundingTxHash == depositKey.FundingTxHash && + event.FundingOutputIndex == depositKey.FundingOutputIndex { + matchingTaprootEvent = event + break + } + } + + if matchingEvent == nil && matchingTaprootEvent == nil { return nil, fmt.Errorf( - "no matching DepositRevealed event for deposit [%v]: [%v]", + "no matching DepositRevealed or TaprootDepositRevealed event for deposit [%v]: [%v]", depositDisplayIndex, err, ) @@ -441,18 +484,40 @@ func ValidateDepositSweepProposal( *Deposit FundingTx *bitcoin.Transaction }{ - Deposit: matchingEvent.unpack(depositRequest.ExtraData), + Deposit: func() *Deposit { + if matchingTaprootEvent != nil { + taprootDepositsCount++ + return matchingTaprootEvent.unpack(depositRequest.ExtraData) + } + + return matchingEvent.unpack(depositRequest.ExtraData) + }(), FundingTx: fundingTx, } } + if taprootDepositsCount > 0 && taprootDepositsCount != len(proposal.DepositsKeys) { + return nil, fmt.Errorf( + "mixed legacy and Taproot deposits are not supported in one sweep proposal", + ) + } + validateProposalLogger.Infof("calling chain for proposal validation") - err := chain.ValidateDepositSweepProposal( - walletPublicKeyHash, - proposal, - depositExtraInfo, - ) + var err error + if taprootDepositsCount > 0 { + err = chain.ValidateTaprootDepositSweepProposal( + walletPublicKeyHash, + proposal, + depositExtraInfo, + ) + } else { + err = chain.ValidateDepositSweepProposal( + walletPublicKeyHash, + proposal, + depositExtraInfo, + ) + } if err != nil { return nil, fmt.Errorf("deposit sweep proposal is invalid: [%v]", err) } @@ -508,6 +573,21 @@ func assembleDepositSweepTransaction( return nil, fmt.Errorf("at least one deposit is required") } + taprootDepositsCount := 0 + for _, deposit := range deposits { + if deposit.IsTaproot() { + taprootDepositsCount++ + } + } + + if taprootDepositsCount > 0 && taprootDepositsCount != len(deposits) { + return nil, fmt.Errorf( + "mixed legacy and Taproot deposits are not supported in one sweep transaction", + ) + } + + taprootSweep := taprootDepositsCount > 0 + builder := bitcoin.NewTransactionBuilder(bitcoinChain) if walletMainUtxo != nil { @@ -521,29 +601,73 @@ func assembleDepositSweepTransaction( } for i, deposit := range deposits { - depositScript, err := deposit.Script() - if err != nil { - return nil, fmt.Errorf( - "cannot get script for deposit [%v]: [%v]", - i, - err, + if deposit.IsTaproot() { + merkleRoot, err := deposit.TaprootMerkleRoot() + if err != nil { + return nil, fmt.Errorf( + "cannot compute Taproot merkle root for deposit [%v]: [%v]", + i, + err, + ) + } + + err = builder.AddTaprootKeyPathInputWithMerkleRoot( + deposit.Utxo, + *deposit.WalletXOnlyPublicKey, + merkleRoot, ) + if err != nil { + return nil, fmt.Errorf( + "cannot add input pointing to Taproot deposit [%v] UTXO: [%v]", + i, + err, + ) + } + } else { + depositScript, err := deposit.Script() + if err != nil { + return nil, fmt.Errorf( + "cannot get script for deposit [%v]: [%v]", + i, + err, + ) + } + + err = builder.AddScriptHashInput(deposit.Utxo, depositScript) + if err != nil { + return nil, fmt.Errorf( + "cannot add input pointing to deposit [%v] UTXO: [%v]", + i, + err, + ) + } } + } + + if taprootSweep && !builder.HasOnlyTaprootKeyPathInputs() { + return nil, fmt.Errorf( + "Taproot deposit sweep requires a Taproot wallet main UTXO", + ) + } - err = builder.AddScriptHashInput(deposit.Utxo, depositScript) + var outputScript bitcoin.Script + var err error + if taprootSweep { + walletXOnlyPublicKey, err := walletXOnlyPublicKey(walletPublicKey) if err != nil { - return nil, fmt.Errorf( - "cannot add input pointing to deposit [%v] UTXO: [%v]", - i, - err, - ) + return nil, err } - } - walletPublicKeyHash := bitcoin.PublicKeyHash(walletPublicKey) - outputScript, err := bitcoin.PayToWitnessPublicKeyHash(walletPublicKeyHash) - if err != nil { - return nil, fmt.Errorf("cannot compute output script: [%v]", err) + outputScript, err = bitcoin.PayToTaproot(walletXOnlyPublicKey) + if err != nil { + return nil, fmt.Errorf("cannot compute Taproot output script: [%v]", err) + } + } else { + walletPublicKeyHash := bitcoin.PublicKeyHash(walletPublicKey) + outputScript, err = bitcoin.PayToWitnessPublicKeyHash(walletPublicKeyHash) + if err != nil { + return nil, fmt.Errorf("cannot compute output script: [%v]", err) + } } outputValue := builder.TotalInputsValue() - fee diff --git a/pkg/tbtc/deposit_sweep_test.go b/pkg/tbtc/deposit_sweep_test.go index 08a2c83eaf..ddf9fbe493 100644 --- a/pkg/tbtc/deposit_sweep_test.go +++ b/pkg/tbtc/deposit_sweep_test.go @@ -2,13 +2,17 @@ package tbtc import ( "context" + "crypto/ecdsa" + "encoding/hex" "fmt" "math/big" "testing" "time" + "github.com/btcsuite/btcd/btcec" "github.com/keep-network/keep-core/internal/testutils" "github.com/keep-network/keep-core/pkg/bitcoin" + "github.com/keep-network/keep-core/pkg/chain" "github.com/keep-network/keep-core/pkg/frost" "github.com/keep-network/keep-core/pkg/tbtc/internal/test" ) @@ -77,7 +81,16 @@ func TestDepositSweepAction_Execute(t *testing.T) { *Deposit FundingTx *bitcoin.Transaction }{ - Deposit: (*Deposit)(deposit), + Deposit: &Deposit{ + Utxo: deposit.Utxo, + Depositor: deposit.Depositor, + BlindingFactor: deposit.BlindingFactor, + WalletPublicKeyHash: deposit.WalletPublicKeyHash, + RefundPublicKeyHash: deposit.RefundPublicKeyHash, + RefundLocktime: deposit.RefundLocktime, + Vault: deposit.Vault, + ExtraData: deposit.ExtraData, + }, FundingTx: fundingTx, } @@ -316,3 +329,382 @@ func TestAssembleDepositSweepTransaction(t *testing.T) { }) } } + +func TestAssembleDepositSweepTransaction_TaprootDeposit(t *testing.T) { + hexToSlice := func(hexString string) []byte { + bytes, err := hex.DecodeString(hexString) + if err != nil { + t.Fatalf("error while converting [%v]: [%v]", hexString, err) + } + return bytes + } + + var walletXOnlyPublicKey [32]byte + copy( + walletXOnlyPublicKey[:], + hexToSlice("2336f65004d8f122f1fe947ebd009a8b4add3a0d937356d568e30f7fcc2e4008"), + ) + + compressedWalletPublicKey := append([]byte{0x02}, walletXOnlyPublicKey[:]...) + parsedWalletPublicKey, err := btcec.ParsePubKey( + compressedWalletPublicKey, + btcec.S256(), + ) + if err != nil { + t.Fatal(err) + } + walletPublicKey := &ecdsa.PublicKey{ + Curve: btcec.S256(), + X: parsedWalletPublicKey.X, + Y: parsedWalletPublicKey.Y, + } + + var refundXOnlyPublicKey [32]byte + copy( + refundXOnlyPublicKey[:], + hexToSlice("11223344556677889900aabbccddeeff00112233445566778899aabbccddeeff"), + ) + + depositOne := &Deposit{ + Depositor: chain.Address("934b98637ca318a4d6e7ca6ffd1690b8e77df637"), + WalletXOnlyPublicKey: &walletXOnlyPublicKey, + RefundXOnlyPublicKey: &refundXOnlyPublicKey, + } + copy(depositOne.BlindingFactor[:], hexToSlice("f9f0c90d00039523")) + copy(depositOne.WalletPublicKeyHash[:], hexToSlice("c92a772f11bc97d8938a16a9db435401f4e6a7bc")) + copy(depositOne.RefundPublicKeyHash[:], hexToSlice("c2a27a88d8d03e271e8edc556923e9398619f17c")) + copy(depositOne.RefundLocktime[:], hexToSlice("60bcea61")) + + merkleRootOne, err := depositOne.TaprootMerkleRoot() + if err != nil { + t.Fatal(err) + } + + fundingOutputScriptOne, err := bitcoin.PayToTaprootWithScriptTree( + walletXOnlyPublicKey, + merkleRootOne, + ) + if err != nil { + t.Fatal(err) + } + + depositTwo := &Deposit{ + Depositor: chain.Address("934b98637ca318a4d6e7ca6ffd1690b8e77df637"), + WalletXOnlyPublicKey: &walletXOnlyPublicKey, + RefundXOnlyPublicKey: &refundXOnlyPublicKey, + } + copy(depositTwo.BlindingFactor[:], hexToSlice("f9f0c90d00039523")) + copy(depositTwo.WalletPublicKeyHash[:], hexToSlice("c92a772f11bc97d8938a16a9db435401f4e6a7bc")) + copy(depositTwo.RefundPublicKeyHash[:], hexToSlice("c2a27a88d8d03e271e8edc556923e9398619f17c")) + copy(depositTwo.RefundLocktime[:], hexToSlice("60bcea61")) + var extraData [32]byte + copy( + extraData[:], + hexToSlice( + "a9b38ea6435c8941d6eda6a46b68e3e2117196995bd154ab55196396b03d9bda", + ), + ) + depositTwo.ExtraData = &extraData + + merkleRootTwo, err := depositTwo.TaprootMerkleRoot() + if err != nil { + t.Fatal(err) + } + + fundingOutputScriptTwo, err := bitcoin.PayToTaprootWithScriptTree( + walletXOnlyPublicKey, + merkleRootTwo, + ) + if err != nil { + t.Fatal(err) + } + + var previousTxHash bitcoin.Hash + copy(previousTxHash[:], hexToSlice("0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20")) + fundingTx := &bitcoin.Transaction{ + Version: 1, + Inputs: []*bitcoin.TransactionInput{ + { + Outpoint: &bitcoin.TransactionOutpoint{ + TransactionHash: previousTxHash, + OutputIndex: 0, + }, + Sequence: 0xffffffff, + }, + }, + Outputs: []*bitcoin.TransactionOutput{ + { + Value: 100000, + PublicKeyScript: fundingOutputScriptOne, + }, + { + Value: 110000, + PublicKeyScript: fundingOutputScriptTwo, + }, + }, + } + + bitcoinChain := newLocalBitcoinChain() + if err := bitcoinChain.BroadcastTransaction(fundingTx); err != nil { + t.Fatal(err) + } + + depositOne.Utxo = &bitcoin.UnspentTransactionOutput{ + Outpoint: &bitcoin.TransactionOutpoint{ + TransactionHash: fundingTx.Hash(), + OutputIndex: 0, + }, + Value: 100000, + } + depositTwo.Utxo = &bitcoin.UnspentTransactionOutput{ + Outpoint: &bitcoin.TransactionOutpoint{ + TransactionHash: fundingTx.Hash(), + OutputIndex: 1, + }, + Value: 110000, + } + + builder, err := assembleDepositSweepTransaction( + bitcoinChain, + walletPublicKey, + nil, + []*Deposit{depositOne, depositTwo}, + 1000, + ) + if err != nil { + t.Fatal(err) + } + + if !builder.HasOnlyTaprootKeyPathInputs() { + t.Fatal("expected only Taproot key-path inputs") + } + + merkleRoots := builder.TaprootKeyPathInputMerkleRoots() + if len(merkleRoots) != 2 || merkleRoots[0] == nil || merkleRoots[1] == nil { + t.Fatalf("expected two Taproot merkle roots") + } + testutils.AssertBytesEqual(t, merkleRootOne[:], merkleRoots[0][:]) + testutils.AssertBytesEqual(t, merkleRootTwo[:], merkleRoots[1][:]) + + unsignedTx := builder.UnsignedTransaction() + if len(unsignedTx.Outputs) != 1 { + t.Fatalf("unexpected outputs count: [%v]", len(unsignedTx.Outputs)) + } + + expectedWalletOutputScript, err := bitcoin.PayToTaproot(walletXOnlyPublicKey) + if err != nil { + t.Fatal(err) + } + testutils.AssertBytesEqual( + t, + expectedWalletOutputScript, + unsignedTx.Outputs[0].PublicKeyScript, + ) + testutils.AssertIntsEqual( + t, + "output value", + 209000, + int(unsignedTx.Outputs[0].Value), + ) +} + +func TestValidateDepositSweepProposal_PrefersTaprootRevealOverCompatibilityReveal(t *testing.T) { + hexToSlice := func(hexString string) []byte { + bytes, err := hex.DecodeString(hexString) + if err != nil { + t.Fatalf("error while converting [%v]: [%v]", hexString, err) + } + return bytes + } + + var fundingTxHash bitcoin.Hash + copy(fundingTxHash[:], hexToSlice("0102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20")) + + fundingTx := &bitcoin.Transaction{ + Version: 1, + Inputs: []*bitcoin.TransactionInput{ + { + Outpoint: &bitcoin.TransactionOutpoint{ + TransactionHash: fundingTxHash, + OutputIndex: 0, + }, + Sequence: 0xffffffff, + }, + }, + Outputs: []*bitcoin.TransactionOutput{ + { + Value: 100000, + PublicKeyScript: bitcoin.Script{ + 0x51, 0x20, + 0x23, 0x36, 0xf6, 0x50, 0x04, 0xd8, 0xf1, 0x22, + 0xf1, 0xfe, 0x94, 0x7e, 0xbd, 0x00, 0x9a, 0x8b, + 0x4a, 0xdd, 0x3a, 0x0d, 0x93, 0x73, 0x56, 0xd5, + 0x68, 0xe3, 0x0f, 0x7f, 0xcc, 0x2e, 0x40, 0x08, + }, + }, + }, + } + + bitcoinChain := newLocalBitcoinChain() + if err := bitcoinChain.BroadcastTransaction(fundingTx); err != nil { + t.Fatal(err) + } + + fundingOutputIndex := uint32(0) + revealBlock := uint64(123) + var blindingFactor [8]byte + copy(blindingFactor[:], hexToSlice("f9f0c90d00039523")) + var walletPublicKeyHash [20]byte + copy(walletPublicKeyHash[:], hexToSlice("c92a772f11bc97d8938a16a9db435401f4e6a7bc")) + var walletXOnlyPublicKey [32]byte + copy( + walletXOnlyPublicKey[:], + hexToSlice("2336f65004d8f122f1fe947ebd009a8b4add3a0d937356d568e30f7fcc2e4008"), + ) + var refundPublicKeyHash [20]byte + copy(refundPublicKeyHash[:], hexToSlice("c2a27a88d8d03e271e8edc556923e9398619f17c")) + var refundXOnlyPublicKey [32]byte + copy( + refundXOnlyPublicKey[:], + hexToSlice("11223344556677889900aabbccddeeff00112233445566778899aabbccddeeff"), + ) + var refundLocktime [4]byte + copy(refundLocktime[:], hexToSlice("60bcea61")) + depositor := chain.Address("934b98637ca318a4d6e7ca6ffd1690b8e77df637") + + proposal := &DepositSweepProposal{ + DepositsKeys: []struct { + FundingTxHash bitcoin.Hash + FundingOutputIndex uint32 + }{ + { + FundingTxHash: fundingTx.Hash(), + FundingOutputIndex: fundingOutputIndex, + }, + }, + SweepTxFee: big.NewInt(1000), + DepositsRevealBlocks: []*big.Int{ + big.NewInt(int64(revealBlock)), + }, + } + + validationChain := &depositSweepValidationChainStub{ + legacyEvents: []*DepositRevealedEvent{ + { + FundingTxHash: fundingTx.Hash(), + FundingOutputIndex: fundingOutputIndex, + Depositor: depositor, + Amount: 100000, + BlindingFactor: blindingFactor, + WalletPublicKeyHash: walletPublicKeyHash, + RefundPublicKeyHash: refundPublicKeyHash, + RefundLocktime: refundLocktime, + BlockNumber: revealBlock, + }, + }, + taprootEvents: []*TaprootDepositRevealedEvent{ + { + FundingTxHash: fundingTx.Hash(), + FundingOutputIndex: fundingOutputIndex, + Depositor: depositor, + Amount: 100000, + BlindingFactor: blindingFactor, + WalletPublicKeyHash: walletPublicKeyHash, + WalletXOnlyPublicKey: walletXOnlyPublicKey, + RefundPublicKeyHash: refundPublicKeyHash, + RefundXOnlyPublicKey: refundXOnlyPublicKey, + RefundLocktime: refundLocktime, + BlockNumber: revealBlock, + }, + }, + depositRequest: &DepositChainRequest{ + Depositor: depositor, + Amount: 100000, + }, + } + + deposits, err := ValidateDepositSweepProposal( + logger.With(), + walletPublicKeyHash, + proposal, + 1, + validationChain, + bitcoinChain, + ) + if err != nil { + t.Fatal(err) + } + + if validationChain.legacyValidationCalled { + t.Fatal("legacy validation should not be called when a Taproot event matches") + } + if !validationChain.taprootValidationCalled { + t.Fatal("Taproot validation was not called") + } + if len(deposits) != 1 { + t.Fatalf("unexpected deposits count: [%v]", len(deposits)) + } + if !deposits[0].IsTaproot() { + t.Fatal("expected validated deposit to be Taproot-native") + } +} + +type depositSweepValidationChainStub struct { + legacyEvents []*DepositRevealedEvent + taprootEvents []*TaprootDepositRevealedEvent + depositRequest *DepositChainRequest + + legacyValidationCalled bool + taprootValidationCalled bool +} + +func (dsvcs *depositSweepValidationChainStub) PastDepositRevealedEvents( + filter *DepositRevealedEventFilter, +) ([]*DepositRevealedEvent, error) { + return dsvcs.legacyEvents, nil +} + +func (dsvcs *depositSweepValidationChainStub) PastTaprootDepositRevealedEvents( + filter *DepositRevealedEventFilter, +) ([]*TaprootDepositRevealedEvent, error) { + return dsvcs.taprootEvents, nil +} + +func (dsvcs *depositSweepValidationChainStub) ValidateDepositSweepProposal( + walletPublicKeyHash [20]byte, + proposal *DepositSweepProposal, + depositsExtraInfo []struct { + *Deposit + FundingTx *bitcoin.Transaction + }, +) error { + dsvcs.legacyValidationCalled = true + return fmt.Errorf("legacy validation should not be called") +} + +func (dsvcs *depositSweepValidationChainStub) ValidateTaprootDepositSweepProposal( + walletPublicKeyHash [20]byte, + proposal *DepositSweepProposal, + depositsExtraInfo []struct { + *Deposit + FundingTx *bitcoin.Transaction + }, +) error { + dsvcs.taprootValidationCalled = true + + if len(depositsExtraInfo) != 1 { + return fmt.Errorf("unexpected deposits extra info count: [%v]", len(depositsExtraInfo)) + } + if !depositsExtraInfo[0].Deposit.IsTaproot() { + return fmt.Errorf("expected Taproot deposit extra info") + } + + return nil +} + +func (dsvcs *depositSweepValidationChainStub) GetDepositRequest( + fundingTxHash bitcoin.Hash, + fundingOutputIndex uint32, +) (*DepositChainRequest, bool, error) { + return dsvcs.depositRequest, true, nil +} diff --git a/pkg/tbtc/deposit_test.go b/pkg/tbtc/deposit_test.go index 72b86344cd..ef978837d7 100644 --- a/pkg/tbtc/deposit_test.go +++ b/pkg/tbtc/deposit_test.go @@ -4,6 +4,7 @@ import ( "encoding/hex" "testing" + "github.com/keep-network/keep-core/pkg/bitcoin" "github.com/keep-network/keep-core/pkg/chain" "github.com/keep-network/keep-core/internal/testutils" @@ -82,3 +83,113 @@ func TestDeposit_Script(t *testing.T) { }) } } + +func TestDeposit_TaprootRefundScript(t *testing.T) { + hexToSlice := func(hexString string) []byte { + bytes, err := hex.DecodeString(hexString) + if err != nil { + t.Fatalf("error while converting [%v]: [%v]", hexString, err) + } + return bytes + } + + var tests = map[string]struct { + extraData string + expectedScript string + expectedMerkleRoot string + expectedTaprootKey string + expectedOutputScript string + }{ + "no extra data": { + extraData: "", + expectedScript: "14934b98637ca318a4d6e7ca6ffd1690b8e77df6377508" + + "f9f0c90d00039523750460bcea61b1752011223344556677889900aabb" + + "ccddeeff00112233445566778899aabbccddeeffac", + expectedMerkleRoot: "3d6f9a2fea1de0a6c260d1fbc0343c9b2ed84307e6a7" + + "231139b78438448ee8c0", + expectedTaprootKey: "90e7ce2b6cd476b7a1c2c7f6585c3fd0eae4379a508e" + + "981ed422b3e28b9ae8c2", + expectedOutputScript: "512090e7ce2b6cd476b7a1c2c7f6585c3fd0eae4379" + + "a508e981ed422b3e28b9ae8c2", + }, + "with extra data": { + extraData: "a9b38ea6435c8941d6eda6a46b68e3e2117196995bd154ab55" + + "196396b03d9bda", + expectedScript: "14934b98637ca318a4d6e7ca6ffd1690b8e77df6377520" + + "a9b38ea6435c8941d6eda6a46b68e3e2117196995bd154ab55196396" + + "b03d9bda7508f9f0c90d00039523750460bcea61b175201122334455" + + "6677889900aabbccddeeff00112233445566778899aabbccddeeffac", + expectedMerkleRoot: "6968648895261db4f667ff977b3bbd9b4684fe756050" + + "894b092fd0e24e24f90f", + expectedTaprootKey: "b57ad22351a7a074b6588836d08fbecae35b61ef9eeb" + + "35376a1c5f3d6049376e", + expectedOutputScript: "5120b57ad22351a7a074b6588836d08fbecae35b61ef" + + "9eeb35376a1c5f3d6049376e", + }, + } + + for testName, test := range tests { + t.Run(testName, func(t *testing.T) { + d := new(Deposit) + d.Depositor = chain.Address("934b98637ca318a4d6e7ca6ffd1690b8e77df637") + copy(d.BlindingFactor[:], hexToSlice("f9f0c90d00039523")) + copy(d.WalletPublicKeyHash[:], hexToSlice("c92a772f11bc97d8938a16a9db435401f4e6a7bc")) + copy(d.RefundPublicKeyHash[:], hexToSlice("c2a27a88d8d03e271e8edc556923e9398619f17c")) + copy(d.RefundLocktime[:], hexToSlice("60bcea61")) + + var walletXOnlyPublicKey [32]byte + copy( + walletXOnlyPublicKey[:], + hexToSlice("2336f65004d8f122f1fe947ebd009a8b4add3a0d937356d568e30f7fcc2e4008"), + ) + d.WalletXOnlyPublicKey = &walletXOnlyPublicKey + + var refundXOnlyPublicKey [32]byte + copy( + refundXOnlyPublicKey[:], + hexToSlice("11223344556677889900aabbccddeeff00112233445566778899aabbccddeeff"), + ) + d.RefundXOnlyPublicKey = &refundXOnlyPublicKey + + if len(test.extraData) > 0 { + var extraData [32]byte + copy(extraData[:], hexToSlice(test.extraData)) + d.ExtraData = &extraData + } + + refundScript, err := d.TaprootRefundScript() + if err != nil { + t.Fatal(err) + } + testutils.AssertBytesEqual(t, hexToSlice(test.expectedScript), refundScript) + + merkleRoot, err := d.TaprootMerkleRoot() + if err != nil { + t.Fatal(err) + } + testutils.AssertBytesEqual(t, hexToSlice(test.expectedMerkleRoot), merkleRoot[:]) + + outputScript, err := bitcoin.PayToTaprootWithScriptTree( + *d.WalletXOnlyPublicKey, + merkleRoot, + ) + if err != nil { + t.Fatal(err) + } + testutils.AssertBytesEqual( + t, + hexToSlice(test.expectedOutputScript), + outputScript, + ) + + outputKey, err := bitcoin.TaprootOutputKey( + *d.WalletXOnlyPublicKey, + &merkleRoot, + ) + if err != nil { + t.Fatal(err) + } + testutils.AssertBytesEqual(t, hexToSlice(test.expectedTaprootKey), outputKey[:]) + }) + } +} diff --git a/pkg/tbtc/frost_dkg_execution_frost_native.go b/pkg/tbtc/frost_dkg_execution_frost_native.go index 0828f1e605..dbf561c697 100644 --- a/pkg/tbtc/frost_dkg_execution_frost_native.go +++ b/pkg/tbtc/frost_dkg_execution_frost_native.go @@ -5,11 +5,15 @@ package tbtc import ( "context" "crypto/ecdsa" + "encoding/hex" + "encoding/json" "fmt" + "math/big" "github.com/btcsuite/btcd/btcec/v2" "go.uber.org/zap" + "github.com/ipfs/go-log/v2" "github.com/keep-network/keep-core/pkg/frost" "github.com/keep-network/keep-core/pkg/frost/registry" frostsigning "github.com/keep-network/keep-core/pkg/frost/signing" @@ -29,11 +33,12 @@ func executeFrostDKGIfPossible( memberIndexes []group.MemberIndex, groupSelectionResult *GroupSelectionResult, ) { - engine := frostsigning.CurrentNativeFROSTDKGEngine() - if engine == nil { + nativeFROSTDKGEngine := frostsigning.CurrentNativeFROSTDKGEngine() + nativeTBTCSignerEngine := frostsigning.CurrentNativeTBTCSignerEngine() + if nativeFROSTDKGEngine == nil && nativeTBTCSignerEngine == nil { logger.Infof( "FROST DKG with seed [0x%x] selected this operator as member "+ - "indexes [%v], but no native FROST DKG engine is registered", + "indexes [%v], but no native FROST DKG or tbtc-signer engine is registered", event.Seed, memberIndexes, ) @@ -126,28 +131,29 @@ func executeFrostDKGIfPossible( return } - nativeResult, err := frostsigning.ExecuteNativeFROSTDKG( + executionResult, err := executeFrostDKG( dkgCtx, dkgLogger, - &frostsigning.NativeFROSTDKGRequest{ - MemberIndex: memberIndex, - GroupSize: len(groupSelectionResult.OperatorsIDs), - Threshold: signatureThreshold, - SessionID: sessionID, - IncludedMembersIndexes: activeMemberIndexes, - Channel: channel, - MembershipValidator: membershipValidator, - }, - engine, + nativeFROSTDKGEngine, + nativeTBTCSignerEngine, + event, + memberIndex, + activeMemberIndexes, + groupSelectionResult, + signatureThreshold, + sessionID, + channel, + membershipValidator, ) if err != nil { - dkgLogger.Errorf("native FROST DKG execution failed: [%v]", err) + dkgLogger.Errorf("FROST DKG execution failed: [%v]", err) return } - if err := registerFrostSigner( + if err := registerFrostSignerWithMaterial( node, - nativeResult, + executionResult.outputKey, + executionResult.signerMaterial, memberIndex, activeMemberIndexes, groupSelectionResult, @@ -156,15 +162,9 @@ func executeFrostDKGIfPossible( return } - outputKey, err := outputKeyFromNativeDKGResult(nativeResult) - if err != nil { - dkgLogger.Errorf("failed to extract FROST DKG output key: [%v]", err) - return - } - unsignedResult, err := registry.AssembleResult( uint64(submitterMemberIndex), - outputKey, + executionResult.outputKey, fullMembers, misbehavedMembersIndices, nil, @@ -227,6 +227,215 @@ func executeFrostDKGIfPossible( } } +type frostDKGExecutionResult struct { + outputKey frost.OutputKey + signerMaterial *frostsigning.NativeSignerMaterial +} + +func executeFrostDKG( + ctx context.Context, + logger log.StandardLogger, + nativeFROSTDKGEngine frostsigning.NativeFROSTDKGEngine, + nativeTBTCSignerEngine frostsigning.NativeTBTCSignerEngine, + event *FrostDKGStartedEvent, + memberIndex group.MemberIndex, + activeMemberIndexes []group.MemberIndex, + groupSelectionResult *GroupSelectionResult, + signatureThreshold int, + sessionID string, + channel net.BroadcastChannel, + membershipValidator *group.MembershipValidator, +) (*frostDKGExecutionResult, error) { + if nativeFROSTDKGEngine != nil { + nativeResult, err := frostsigning.ExecuteNativeFROSTDKG( + ctx, + logger, + &frostsigning.NativeFROSTDKGRequest{ + MemberIndex: memberIndex, + GroupSize: len(groupSelectionResult.OperatorsIDs), + Threshold: signatureThreshold, + SessionID: sessionID, + IncludedMembersIndexes: activeMemberIndexes, + Channel: channel, + MembershipValidator: membershipValidator, + }, + nativeFROSTDKGEngine, + ) + if err != nil { + return nil, fmt.Errorf("native FROST DKG execution failed: [%w]", err) + } + + signerMaterial, err := nativeResult.SignerMaterial() + if err != nil { + return nil, err + } + + outputKey, err := outputKeyFromNativeDKGResult(nativeResult) + if err != nil { + return nil, err + } + + return &frostDKGExecutionResult{ + outputKey: outputKey, + signerMaterial: signerMaterial, + }, nil + } + + return executeTBTCSignerFROSTDKG( + nativeTBTCSignerEngine, + event, + activeMemberIndexes, + signatureThreshold, + sessionID, + ) +} + +func executeTBTCSignerFROSTDKG( + nativeEngine frostsigning.NativeTBTCSignerEngine, + event *FrostDKGStartedEvent, + activeMemberIndexes []group.MemberIndex, + signatureThreshold int, + sessionID string, +) (*frostDKGExecutionResult, error) { + if nativeEngine == nil { + return nil, fmt.Errorf("native tbtc-signer engine is unavailable") + } + + seededEngine, ok := nativeEngine.(frostsigning.NativeTBTCSignerSeededDKGEngine) + if !ok { + return nil, fmt.Errorf("native tbtc-signer engine does not support seeded DKG") + } + + dkgSeedHex, err := frostDKGSeedHex(event.Seed) + if err != nil { + return nil, err + } + + participants, err := nativeTBTCSignerDKGParticipants(activeMemberIndexes) + if err != nil { + return nil, err + } + + if signatureThreshold <= 0 || signatureThreshold > int(^uint16(0)) { + return nil, fmt.Errorf( + "invalid tbtc-signer DKG threshold [%d]", + signatureThreshold, + ) + } + + dkgResult, err := seededEngine.RunDKGWithSeed( + sessionID, + participants, + uint16(signatureThreshold), + dkgSeedHex, + ) + if err != nil { + return nil, fmt.Errorf("tbtc-signer RunDKG failed: [%w]", err) + } + + outputKey, err := outputKeyFromTBTCSignerDKGResult(dkgResult) + if err != nil { + return nil, err + } + + payload, err := json.Marshal(frostsigning.NativeTBTCSignerMaterialPayload{ + KeyGroup: dkgResult.KeyGroup, + TaprootOutputKey: hex.EncodeToString(outputKey[:]), + KeyGroupSource: frostsigning.NativeTBTCSignerKeyGroupSourceDKGPersisted, + DKGSeedHex: dkgSeedHex, + DKGParticipants: participants, + DKGThreshold: uint16(signatureThreshold), + }) + if err != nil { + return nil, fmt.Errorf("cannot marshal tbtc-signer material: [%w]", err) + } + + return &frostDKGExecutionResult{ + outputKey: outputKey, + signerMaterial: &frostsigning.NativeSignerMaterial{ + Format: frostsigning.NativeSignerMaterialFormatFrostTBTCSignerV1, + Payload: payload, + }, + }, nil +} + +func nativeTBTCSignerDKGParticipants( + activeMemberIndexes []group.MemberIndex, +) ([]frostsigning.NativeTBTCSignerDKGParticipant, error) { + participants := make( + []frostsigning.NativeTBTCSignerDKGParticipant, + 0, + len(activeMemberIndexes), + ) + + for _, memberIndex := range activeMemberIndexes { + if memberIndex == 0 { + return nil, fmt.Errorf( + "invalid tbtc-signer DKG member index [%d]", + memberIndex, + ) + } + + identifier := uint16(memberIndex) + participants = append( + participants, + frostsigning.NativeTBTCSignerDKGParticipant{ + Identifier: identifier, + PublicKeyHex: frostsigning. + NativeTBTCSignerDKGPlaceholderPublicKeyHex(identifier), + }, + ) + } + + return participants, nil +} + +func frostDKGSeedHex(seed *big.Int) (string, error) { + if seed == nil { + return "", fmt.Errorf("FROST DKG seed is nil") + } + if seed.Sign() < 0 || len(seed.Bytes()) > frost.OutputKeySize { + return "", fmt.Errorf("FROST DKG seed must fit in %d bytes", frost.OutputKeySize) + } + + seedBytes := make([]byte, frost.OutputKeySize) + seed.FillBytes(seedBytes) + + return hex.EncodeToString(seedBytes), nil +} + +func outputKeyFromTBTCSignerDKGResult( + dkgResult *frostsigning.NativeTBTCSignerDKGResult, +) (frost.OutputKey, error) { + if dkgResult == nil { + return frost.OutputKey{}, fmt.Errorf("tbtc-signer DKG result is nil") + } + if dkgResult.KeyGroup == "" { + return frost.OutputKey{}, fmt.Errorf("tbtc-signer DKG key group is empty") + } + + outputKeyBytes, err := frostsigning.TaprootOutputKeyFromTBTCSignerKey( + dkgResult.KeyGroup, + ) + if err != nil { + return frost.OutputKey{}, fmt.Errorf( + "cannot derive tbtc-signer DKG Taproot output key: [%w]", + err, + ) + } + if len(outputKeyBytes) != frost.OutputKeySize { + return frost.OutputKey{}, fmt.Errorf( + "unexpected tbtc-signer DKG output key length [%d]", + len(outputKeyBytes), + ) + } + + var outputKey frost.OutputKey + copy(outputKey[:], outputKeyBytes) + + return outputKey, nil +} + func announceFrostDKGReadiness( ctx context.Context, node *node, @@ -302,6 +511,28 @@ func registerFrostSigner( return err } + return registerFrostSignerWithMaterial( + node, + outputKey, + signerMaterial, + memberIndex, + activeMemberIndexes, + groupSelectionResult, + ) +} + +func registerFrostSignerWithMaterial( + node *node, + outputKey frost.OutputKey, + signerMaterial *frostsigning.NativeSignerMaterial, + memberIndex group.MemberIndex, + activeMemberIndexes []group.MemberIndex, + groupSelectionResult *GroupSelectionResult, +) error { + if signerMaterial == nil { + return fmt.Errorf("FROST signer material is nil") + } + walletPublicKey, err := frostOutputKeyToECDSAPublicKey(outputKey) if err != nil { return err @@ -398,7 +629,7 @@ func outputKeyFromNativeDKGResult( return frost.OutputKey{}, err } - outputKeyBytes, err := frostsigning.ExtractDkgGroupPublicKeyFromMaterial( + outputKeyBytes, err := frostsigning.ExtractTaprootOutputKeyFromMaterial( signerMaterial, ) if err != nil { diff --git a/pkg/tbtc/frost_dkg_execution_frost_native_test.go b/pkg/tbtc/frost_dkg_execution_frost_native_test.go index 7b9deb785d..a60b1f700b 100644 --- a/pkg/tbtc/frost_dkg_execution_frost_native_test.go +++ b/pkg/tbtc/frost_dkg_execution_frost_native_test.go @@ -3,9 +3,12 @@ package tbtc import ( + "bytes" + "encoding/hex" "testing" "github.com/keep-network/keep-core/pkg/frost/registry" + frostsigning "github.com/keep-network/keep-core/pkg/frost/signing" "github.com/keep-network/keep-core/pkg/protocol/group" ) @@ -71,3 +74,28 @@ func TestFrostMisbehavedMemberIndices(t *testing.T) { } } } + +func TestOutputKeyFromTBTCSignerDKGResult_AcceptsCompressedKeyGroup( + t *testing.T, +) { + const compressedKey = "0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798" + const xOnlyKey = "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798" + + outputKey, err := outputKeyFromTBTCSignerDKGResult( + &frostsigning.NativeTBTCSignerDKGResult{ + KeyGroup: compressedKey, + }, + ) + if err != nil { + t.Fatalf("output key: %v", err) + } + + want, _ := hex.DecodeString(xOnlyKey) + if !bytes.Equal(outputKey[:], want) { + t.Fatalf( + "unexpected output key\nexpected: [%x]\nactual: [%x]", + want, + outputKey[:], + ) + } +} diff --git a/pkg/tbtc/moved_funds_sweep.go b/pkg/tbtc/moved_funds_sweep.go index 2569f4557d..55682e49f4 100644 --- a/pkg/tbtc/moved_funds_sweep.go +++ b/pkg/tbtc/moved_funds_sweep.go @@ -161,8 +161,8 @@ func (mfsa *movedFundsSweepAction) execute() error { } // Prepare the wallet's main UTXO. - walletMainUtxo, err := DetermineWalletMainUtxo( - walletPublicKeyHash, + walletMainUtxo, err := DetermineWalletMainUtxoForPublicKey( + mfsa.wallet().publicKey, mfsa.chain, mfsa.btcChain, ) @@ -173,8 +173,8 @@ func (mfsa *movedFundsSweepAction) execute() error { ) } - err = EnsureWalletSyncedBetweenChains( - walletPublicKeyHash, + err = EnsureWalletSyncedBetweenChainsForPublicKey( + mfsa.wallet().publicKey, walletMainUtxo, mfsa.chain, mfsa.btcChain, diff --git a/pkg/tbtc/moving_funds.go b/pkg/tbtc/moving_funds.go index 1e9c01b0a3..345b50c198 100644 --- a/pkg/tbtc/moving_funds.go +++ b/pkg/tbtc/moving_funds.go @@ -133,8 +133,8 @@ func (mfa *movingFundsAction) execute() error { walletPublicKeyHash := bitcoin.PublicKeyHash(mfa.wallet().publicKey) - walletMainUtxo, err := DetermineWalletMainUtxo( - walletPublicKeyHash, + walletMainUtxo, err := DetermineWalletMainUtxoForPublicKey( + mfa.wallet().publicKey, mfa.chain, mfa.btcChain, ) @@ -151,6 +151,14 @@ func (mfa *movingFundsAction) execute() error { return fmt.Errorf("moving funds wallet has no main UTXO") } + err = ensureMovingFundsMainUtxoSupportsLegacyTargets( + mfa.btcChain, + walletMainUtxo, + ) + if err != nil { + return fmt.Errorf("unsupported moving funds wallet main UTXO: [%v]", err) + } + // Perform initial validation of the moving funds proposal. err = ValidateMovingFundsProposal( validateProposalLogger, @@ -188,8 +196,8 @@ func (mfa *movingFundsAction) execute() error { return fmt.Errorf("validate proposal step failed: [%v]", err) } - err = EnsureWalletSyncedBetweenChains( - walletPublicKeyHash, + err = EnsureWalletSyncedBetweenChainsForPublicKey( + mfa.wallet().publicKey, walletMainUtxo, mfa.chain, mfa.btcChain, @@ -574,8 +582,16 @@ func assembleMovingFundsTransaction( return nil, fmt.Errorf("wallet main UTXO is required") } + err := ensureMovingFundsMainUtxoSupportsLegacyTargets( + bitcoinChain, + walletMainUtxo, + ) + if err != nil { + return nil, err + } + builder := bitcoin.NewTransactionBuilder(bitcoinChain) - err := builder.AddPublicKeyHashInput(walletMainUtxo) + err = builder.AddPublicKeyHashInput(walletMainUtxo) if err != nil { return nil, fmt.Errorf( "cannot add input pointing to wallet main UTXO: [%v]", @@ -627,3 +643,45 @@ func assembleMovingFundsTransaction( return builder, nil } + +func ensureMovingFundsMainUtxoSupportsLegacyTargets( + bitcoinChain bitcoin.Chain, + walletMainUtxo *bitcoin.UnspentTransactionOutput, +) error { + if walletMainUtxo.Outpoint == nil { + return fmt.Errorf("wallet main UTXO outpoint is required") + } + + transaction, err := bitcoinChain.GetTransaction( + walletMainUtxo.Outpoint.TransactionHash, + ) + if err != nil { + return fmt.Errorf( + "cannot get transaction with hash [%s]: [%v]", + walletMainUtxo.Outpoint.TransactionHash.Hex(bitcoin.InternalByteOrder), + err, + ) + } + + outputIndex := walletMainUtxo.Outpoint.OutputIndex + if outputIndex >= uint32(len(transaction.Outputs)) { + return fmt.Errorf( + "output index [%d] out of range for transaction [%s] "+ + "with [%d] outputs", + outputIndex, + walletMainUtxo.Outpoint.TransactionHash.Hex(bitcoin.InternalByteOrder), + len(transaction.Outputs), + ) + } + + if bitcoin.GetScriptType( + transaction.Outputs[outputIndex].PublicKeyScript, + ) == bitcoin.P2TRScript { + return fmt.Errorf( + "Taproot moving-funds main UTXOs are not supported until " + + "P2TR target wallet outputs are implemented", + ) + } + + return nil +} diff --git a/pkg/tbtc/moving_funds_test.go b/pkg/tbtc/moving_funds_test.go index 42134aec60..5609efc820 100644 --- a/pkg/tbtc/moving_funds_test.go +++ b/pkg/tbtc/moving_funds_test.go @@ -6,6 +6,7 @@ import ( "fmt" "math/big" "reflect" + "strings" "testing" "time" @@ -226,6 +227,63 @@ func TestAssembleMovingFundsTransaction(t *testing.T) { } } +func TestAssembleMovingFundsTransaction_RejectsTaprootWalletMainUtxo( + t *testing.T, +) { + var taprootOutputKey [32]byte + taprootOutputKey[31] = 1 + + taprootScript, err := bitcoin.PayToTaproot(taprootOutputKey) + if err != nil { + t.Fatal(err) + } + + fundingTx := &bitcoin.Transaction{ + Version: 1, + Inputs: []*bitcoin.TransactionInput{ + { + Outpoint: &bitcoin.TransactionOutpoint{ + TransactionHash: bitcoin.Hash{}, + OutputIndex: 0, + }, + Sequence: 0xffffffff, + }, + }, + Outputs: []*bitcoin.TransactionOutput{ + { + Value: 100000, + PublicKeyScript: taprootScript, + }, + }, + } + + bitcoinChain := newLocalBitcoinChain() + if err := bitcoinChain.BroadcastTransaction(fundingTx); err != nil { + t.Fatal(err) + } + + _, err = assembleMovingFundsTransaction( + bitcoinChain, + &bitcoin.UnspentTransactionOutput{ + Outpoint: &bitcoin.TransactionOutpoint{ + TransactionHash: fundingTx.Hash(), + OutputIndex: 0, + }, + Value: 100000, + }, + [][20]byte{ + hexToByte20("c7302d75072d78be94eb8d36c4b77583c7abb06e"), + }, + 1000, + ) + if err == nil { + t.Fatal("expected Taproot moving-funds main UTXO rejection") + } + if !strings.Contains(err.Error(), "Taproot moving-funds main UTXOs") { + t.Fatalf("unexpected error: [%v]", err) + } +} + func TestValidateMovingFundsSafetyMargin(t *testing.T) { walletPublicKeyHash := hexToByte20( "ffb3f7538bfa98a511495dd96027cfbd57baf2fa", diff --git a/pkg/tbtc/node.go b/pkg/tbtc/node.go index 03801a4e72..ff605a1d8b 100644 --- a/pkg/tbtc/node.go +++ b/pkg/tbtc/node.go @@ -188,21 +188,23 @@ func newNode( return nil, fmt.Errorf("cannot get node's operator address: [%v]", err) } - // TODO: This chicken and egg problem should be solved when - // waitForBlockHeight becomes a part of BlockHeightWaiter interface. - node.dkgExecutor = newDkgExecutor( - node.groupParameters, - node.operatorID, - operatorAddress, - chain, - netProvider, - walletRegistry, - latch, - config, - workPersistence, - scheduler, - node.waitForBlockHeight, - ) + if shouldRunLegacyECDSA(config) { + // TODO: This chicken and egg problem should be solved when + // waitForBlockHeight becomes a part of BlockHeightWaiter interface. + node.dkgExecutor = newDkgExecutor( + node.groupParameters, + node.operatorID, + operatorAddress, + chain, + netProvider, + walletRegistry, + latch, + config, + workPersistence, + scheduler, + node.waitForBlockHeight, + ) + } return node, nil } @@ -329,6 +331,11 @@ func (n *node) joinDKGIfEligible( startBlock uint64, delayBlocks uint64, ) { + if n.dkgExecutor == nil { + logger.Warnf("legacy ECDSA DKG is disabled; ignoring DKG started event") + return + } + n.dkgExecutor.executeDkgIfEligible(seed, startBlock, delayBlocks) } @@ -343,6 +350,11 @@ func (n *node) validateDKG( result *DKGChainResult, resultHash [32]byte, ) { + if n.dkgExecutor == nil { + logger.Warnf("legacy ECDSA DKG is disabled; ignoring DKG result") + return + } + n.dkgExecutor.executeDkgValidation(seed, submissionBlock, result, resultHash) } @@ -1313,7 +1325,7 @@ func (n *node) archiveClosedWallets() error { walletPublicKeyHash := bitcoin.PublicKeyHash(walletPublicKey) var walletID [32]byte - var ecdsaWalletID [32]byte + var archiveWallet bool walletChainData, err := n.chain.GetWallet(walletPublicKeyHash) if err != nil { @@ -1327,40 +1339,44 @@ func (n *node) archiveClosedWallets() error { ) } - // Legacy fallback for deployments where canonical wallet lookup - // is unavailable. - ecdsaWalletID = walletID + // Legacy fallback for deployments where Bridge wallet state is + // unavailable. FROST wallets are registered in the Bridge but not + // in the legacy ECDSA wallet registry. + isRegistered, err := n.chain.IsWalletRegistered(walletID) + if err != nil { + return fmt.Errorf( + "could not check if wallet is registered for wallet with ECDSA ID "+ + "[0x%x]: [%v]", + walletID, + err, + ) + } + + if !isRegistered && n.frostWalletRegistryAvailable() { + logger.Infof( + "wallet with ECDSA ID [0x%x] and public key hash [0x%x] "+ + "was not found in Bridge or the legacy ECDSA registry; "+ + "preserving local key material because FROST wallet "+ + "registration is available and the wallet may be "+ + "pending Bridge registration", + walletID, + walletPublicKeyHash, + ) + continue + } + + archiveWallet = !isRegistered } else { walletID = walletChainData.WalletID if walletID == [32]byte{} { walletID = DeriveLegacyWalletID(walletPublicKeyHash) } - ecdsaWalletID = walletChainData.EcdsaWalletID - if ecdsaWalletID == [32]byte{} { - ecdsaWalletID, err = n.chain.CalculateWalletID(walletPublicKey) - if err != nil { - return fmt.Errorf( - "could not calculate ECDSA wallet ID for wallet with public key "+ - "hash [0x%x]: [%v]", - walletPublicKeyHash, - err, - ) - } - } - } - - isRegistered, err := n.chain.IsWalletRegistered(ecdsaWalletID) - if err != nil { - return fmt.Errorf( - "could not check if wallet is registered for wallet with ECDSA ID "+ - "[0x%x]: [%v]", - ecdsaWalletID, - err, - ) + archiveWallet = walletChainData.State == StateClosed || + walletChainData.State == StateTerminated } - if !isRegistered { + if archiveWallet { // If the wallet is no longer registered it means the wallet has // been closed or terminated. err := n.walletRegistry.archiveWallet(walletPublicKeyHash) @@ -1384,6 +1400,16 @@ func (n *node) archiveClosedWallets() error { return nil } +type frostWalletRegistryAvailability interface { + FrostWalletRegistryAvailable() bool +} + +func (n *node) frostWalletRegistryAvailable() bool { + frostChain, ok := n.chain.(frostWalletRegistryAvailability) + + return ok && frostChain.FrostWalletRegistryAvailable() +} + // handleWalletClosure handles the wallet termination or closing process. func (n *node) handleWalletClosure(walletID [32]byte) error { blockCounter, err := n.chain.BlockCounter() diff --git a/pkg/tbtc/node_test.go b/pkg/tbtc/node_test.go index 967cb79ece..ae18a37c70 100644 --- a/pkg/tbtc/node_test.go +++ b/pkg/tbtc/node_test.go @@ -285,6 +285,138 @@ func TestNode_GetCoordinationExecutor(t *testing.T) { } } +func TestNode_KeepsLiveBridgeWalletWithoutLegacyRegistration(t *testing.T) { + groupParameters := &GroupParameters{ + GroupSize: 5, + GroupQuorum: 4, + HonestThreshold: 3, + } + + localChain := Connect() + localProvider := local.Connect() + + signer := createMockSigner(t) + walletPublicKeyHash := bitcoin.PublicKeyHash(signer.wallet.publicKey) + + localChain.setWallet( + walletPublicKeyHash, + &WalletChainData{ + WalletID: [32]byte{31: 0x01}, + State: StateLive, + }, + ) + + n, err := newNode( + groupParameters, + localChain, + newLocalBitcoinChain(), + localProvider, + createMockKeyStorePersistence(t, signer), + &mockPersistenceHandle{}, + generator.StartScheduler(), + &mockCoordinationProposalGenerator{}, + Config{}, + ) + if err != nil { + t.Fatal(err) + } + + _, ok := n.walletRegistry.getWalletByPublicKeyHash(walletPublicKeyHash) + if !ok { + t.Fatal("live Bridge wallet should not be archived") + } +} + +func TestNode_KeepsPendingFrostWalletWithoutBridgeRegistration(t *testing.T) { + groupParameters := &GroupParameters{ + GroupSize: 5, + GroupQuorum: 4, + HonestThreshold: 3, + } + + localChain := Connect() + localChain.frostWalletRegistryAvailable = true + localProvider := local.Connect() + + signer := createMockSigner(t) + walletPublicKeyHash := bitcoin.PublicKeyHash(signer.wallet.publicKey) + + n, err := newNode( + groupParameters, + localChain, + newLocalBitcoinChain(), + localProvider, + createMockKeyStorePersistence(t, signer), + &mockPersistenceHandle{}, + generator.StartScheduler(), + &mockCoordinationProposalGenerator{}, + Config{}, + ) + if err != nil { + t.Fatal(err) + } + + _, ok := n.walletRegistry.getWalletByPublicKeyHash(walletPublicKeyHash) + if !ok { + t.Fatal("pending FROST wallet should not be archived") + } +} + +func TestNode_ArchivesClosedBridgeWallet(t *testing.T) { + testCases := map[string]WalletState{ + "closed": StateClosed, + "terminated": StateTerminated, + } + + for name, walletState := range testCases { + t.Run(name, func(t *testing.T) { + groupParameters := &GroupParameters{ + GroupSize: 5, + GroupQuorum: 4, + HonestThreshold: 3, + } + + localChain := Connect() + localProvider := local.Connect() + + signer := createMockSigner(t) + walletPublicKeyHash := bitcoin.PublicKeyHash( + signer.wallet.publicKey, + ) + + localChain.setWallet( + walletPublicKeyHash, + &WalletChainData{ + WalletID: [32]byte{31: 0x01}, + State: walletState, + }, + ) + + n, err := newNode( + groupParameters, + localChain, + newLocalBitcoinChain(), + localProvider, + createMockKeyStorePersistence(t, signer), + &mockPersistenceHandle{}, + generator.StartScheduler(), + &mockCoordinationProposalGenerator{}, + Config{}, + ) + if err != nil { + t.Fatal(err) + } + + _, ok := n.walletRegistry.getWalletByPublicKeyHash( + walletPublicKeyHash, + ) + if ok { + t.Fatal("closed Bridge wallet should be archived") + } + }) + } +} + func TestNode_RunCoordinationLayer(t *testing.T) { groupParameters := &GroupParameters{ GroupSize: 5, diff --git a/pkg/tbtc/redemption.go b/pkg/tbtc/redemption.go index 1dd950c95f..53064f887a 100644 --- a/pkg/tbtc/redemption.go +++ b/pkg/tbtc/redemption.go @@ -191,8 +191,8 @@ func (ra *redemptionAction) execute() error { return fmt.Errorf("validate proposal step failed: [%v]", err) } - walletMainUtxo, err := DetermineWalletMainUtxo( - walletPublicKeyHash, + walletMainUtxo, err := DetermineWalletMainUtxoForPublicKey( + ra.wallet().publicKey, ra.chain, ra.btcChain, ) @@ -215,8 +215,8 @@ func (ra *redemptionAction) execute() error { return fmt.Errorf("redeeming wallet has no main UTXO") } - err = EnsureWalletSyncedBetweenChains( - walletPublicKeyHash, + err = EnsureWalletSyncedBetweenChainsForPublicKey( + ra.wallet().publicKey, walletMainUtxo, ra.chain, ra.btcChain, @@ -508,14 +508,31 @@ func assembleRedemptionTransaction( // If we can have a non-zero change, construct it. if changeOutputValue > 0 { - changeOutputScript, err := bitcoin.PayToWitnessPublicKeyHash( - bitcoin.PublicKeyHash(walletPublicKey), - ) - if err != nil { - return nil, fmt.Errorf( - "cannot compute change output script: [%v]", - err, + var changeOutputScript bitcoin.Script + var err error + if builder.HasOnlyTaprootKeyPathInputs() { + walletXOnlyPublicKey, err := walletXOnlyPublicKey(walletPublicKey) + if err != nil { + return nil, err + } + + changeOutputScript, err = bitcoin.PayToTaproot(walletXOnlyPublicKey) + if err != nil { + return nil, fmt.Errorf( + "cannot compute Taproot change output script: [%v]", + err, + ) + } + } else { + changeOutputScript, err = bitcoin.PayToWitnessPublicKeyHash( + bitcoin.PublicKeyHash(walletPublicKey), ) + if err != nil { + return nil, fmt.Errorf( + "cannot compute change output script: [%v]", + err, + ) + } } changeOutput := &bitcoin.TransactionOutput{ diff --git a/pkg/tbtc/signing.go b/pkg/tbtc/signing.go index c7c3d33677..12b76cd6af 100644 --- a/pkg/tbtc/signing.go +++ b/pkg/tbtc/signing.go @@ -2,6 +2,8 @@ package tbtc import ( "context" + "crypto/sha256" + "encoding/binary" "fmt" "math/big" "strings" @@ -41,6 +43,29 @@ const ( // cannot execute the requested signature due to an ongoing signing. var errSigningExecutorBusy = fmt.Errorf("signing executor is busy") +func signingSessionID( + message *big.Int, + taprootMerkleRoot *[32]byte, + startBlock uint64, + attemptNumber uint, +) string { + if taprootMerkleRoot == nil { + return fmt.Sprintf("%v-%v", message.Text(16), attemptNumber) + } + + var startBlockBytes [8]byte + binary.BigEndian.PutUint64(startBlockBytes[:], startBlock) + + sessionDigest := sha256.New() + sessionDigest.Write([]byte(message.Text(16))) + sessionDigest.Write([]byte{0}) + sessionDigest.Write(taprootMerkleRoot[:]) + sessionDigest.Write([]byte{0}) + sessionDigest.Write(startBlockBytes[:]) + + return fmt.Sprintf("tr-%x-%v", sessionDigest.Sum(nil), attemptNumber) +} + // signingExecutor is a component responsible for executing signing related to // a specific wallet whose part is controlled by this node. type signingExecutor struct { @@ -104,6 +129,23 @@ func (se *signingExecutor) signBatch( messages []*big.Int, startBlock uint64, ) ([]*frost.Signature, error) { + return se.signBatchWithTaprootMerkleRoots(ctx, messages, nil, startBlock) +} + +func (se *signingExecutor) signBatchWithTaprootMerkleRoots( + ctx context.Context, + messages []*big.Int, + taprootMerkleRoots []*[32]byte, + startBlock uint64, +) ([]*frost.Signature, error) { + if taprootMerkleRoots != nil && len(taprootMerkleRoots) != len(messages) { + return nil, fmt.Errorf( + "taproot merkle roots count [%v] does not match messages count [%v]", + len(taprootMerkleRoots), + len(messages), + ) + } + wallet := se.wallet() walletPublicKeyBytes, err := marshalPublicKey(wallet.publicKey) @@ -155,7 +197,17 @@ func (se *signingExecutor) signBatch( signingStartBlock = endBlocks[i-1] + signingBatchInterludeBlocks } - signature, _, endBlock, err := se.sign(ctx, message, signingStartBlock) + var taprootMerkleRoot *[32]byte + if taprootMerkleRoots != nil { + taprootMerkleRoot = taprootMerkleRoots[i] + } + + signature, _, endBlock, err := se.signWithTaprootMerkleRoot( + ctx, + message, + taprootMerkleRoot, + signingStartBlock, + ) if err != nil { // Error metrics are recorded in the sign() method for all error paths. return nil, err @@ -185,6 +237,15 @@ func (se *signingExecutor) sign( ctx context.Context, message *big.Int, startBlock uint64, +) (*frost.Signature, *signingActivityReport, uint64, error) { + return se.signWithTaprootMerkleRoot(ctx, message, nil, startBlock) +} + +func (se *signingExecutor) signWithTaprootMerkleRoot( + ctx context.Context, + message *big.Int, + taprootMerkleRoot *[32]byte, + startBlock uint64, ) (*frost.Signature, *signingActivityReport, uint64, error) { if lockAcquired := se.lock.TryAcquire(1); !lockAcquired { // Record failure metrics for lock acquisition failure @@ -340,9 +401,10 @@ func (se *signingExecutor) sign( se.waitForBlockFn, ) - sessionID := fmt.Sprintf( - "%v-%v", - message.Text(16), + sessionID := signingSessionID( + message, + taprootMerkleRoot, + startBlock, attempt.number, ) @@ -350,12 +412,13 @@ func (se *signingExecutor) sign( attemptCtx, signingAttemptLogger, &signing.Request{ - Message: message, - SessionID: sessionID, - MemberIndex: signer.signingGroupMemberIndex, - SignerMaterial: signer.signingMaterial(), - PrivateKeyShare: signer.privateKeyShare, - GroupSize: wallet.groupSize(), + Message: message, + SessionID: sessionID, + MemberIndex: signer.signingGroupMemberIndex, + SignerMaterial: signer.signingMaterial(), + PrivateKeyShare: signer.privateKeyShare, + TaprootMerkleRoot: taprootMerkleRoot, + GroupSize: wallet.groupSize(), DishonestThreshold: wallet.groupDishonestThreshold( se.groupParameters.HonestThreshold, ), diff --git a/pkg/tbtc/signing_native_backend_frost_native_test.go b/pkg/tbtc/signing_native_backend_frost_native_test.go index cbd45b120d..89444fe244 100644 --- a/pkg/tbtc/signing_native_backend_frost_native_test.go +++ b/pkg/tbtc/signing_native_backend_frost_native_test.go @@ -215,7 +215,10 @@ func (atntsfe *attemptTrackingNativeTBTCSignerEngineForTBTC) StartSignRound( message []byte, keyGroup string, signingParticipants []uint16, + taprootMerkleRoot *[32]byte, ) (*frostsigning.NativeTBTCSignerRoundState, error) { + _ = taprootMerkleRoot + attemptNumber, err := attemptNumberFromSessionIDForTBTC(sessionID) if err != nil { return nil, err @@ -265,7 +268,10 @@ func (atntsfe *attemptTrackingNativeTBTCSignerEngineForTBTC) StartSignRound( func (atntsfe *attemptTrackingNativeTBTCSignerEngineForTBTC) FinalizeSignRound( sessionID string, roundContributions []frostsigning.NativeTBTCSignerRoundContribution, + taprootMerkleRoot *[32]byte, ) ([]byte, error) { + _ = taprootMerkleRoot + if _, err := attemptNumberFromSessionIDForTBTC(sessionID); err != nil { return nil, err } diff --git a/pkg/tbtc/signing_test.go b/pkg/tbtc/signing_test.go index 9ac73be7ee..de12bc9ddd 100644 --- a/pkg/tbtc/signing_test.go +++ b/pkg/tbtc/signing_test.go @@ -4,6 +4,7 @@ import ( "context" "crypto/ecdsa" "math/big" + "strings" "testing" "time" @@ -19,6 +20,68 @@ import ( "github.com/keep-network/keep-core/pkg/tecdsa" ) +func TestSigningSessionID_LegacyFormat(t *testing.T) { + message, ok := new(big.Int).SetString( + "ac692bb7fddf3f7e1e050a83cf3ffb6e8e69888ce980281aa39da169525750ef", + 16, + ) + if !ok { + t.Fatal("failed to build test message") + } + + sessionID := signingSessionID(message, nil, 25300, 12) + + expected := "ac692bb7fddf3f7e1e050a83cf3ffb6e8e69888ce980281aa39da169525750ef-12" + if sessionID != expected { + t.Fatalf( + "unexpected signing session ID\nexpected: [%s]\nactual: [%s]", + expected, + sessionID, + ) + } +} + +func TestSigningSessionID_TaprootFormatStaysWithinSignerLimit(t *testing.T) { + message, ok := new(big.Int).SetString( + "ac692bb7fddf3f7e1e050a83cf3ffb6e8e69888ce980281aa39da169525750ef", + 16, + ) + if !ok { + t.Fatal("failed to build test message") + } + + var merkleRoot [32]byte + for i := range merkleRoot { + merkleRoot[i] = byte(i + 1) + } + + sessionID := signingSessionID(message, &merkleRoot, 25300, 12) + + if len(sessionID) > 128 { + t.Fatalf("Taproot signing session ID exceeds signer limit: [%d]", len(sessionID)) + } + if !strings.HasPrefix(sessionID, "tr-") { + t.Fatalf("unexpected Taproot signing session ID prefix: [%s]", sessionID) + } + if !strings.HasSuffix(sessionID, "-12") { + t.Fatalf("unexpected Taproot signing session ID attempt suffix: [%s]", sessionID) + } + + changedMerkleRoot := merkleRoot + changedMerkleRoot[0] ^= 0xff + if signingSessionID(message, &changedMerkleRoot, 25300, 12) == sessionID { + t.Fatal("expected Taproot signing session ID to bind the merkle root") + } + + if signingSessionID(message, &merkleRoot, 25300, 13) == sessionID { + t.Fatal("expected Taproot signing session ID to bind the attempt number") + } + + if signingSessionID(message, &merkleRoot, 28900, 12) == sessionID { + t.Fatal("expected Taproot signing session ID to bind the signing start block") + } +} + func TestSigningExecutor_Sign(t *testing.T) { executor := setupSigningExecutor(t) diff --git a/pkg/tbtc/taproot_wallet.go b/pkg/tbtc/taproot_wallet.go new file mode 100644 index 0000000000..51c4653cd3 --- /dev/null +++ b/pkg/tbtc/taproot_wallet.go @@ -0,0 +1,20 @@ +package tbtc + +import ( + "crypto/ecdsa" + "fmt" + + "github.com/keep-network/keep-core/pkg/internal/byteutils" +) + +func walletXOnlyPublicKey(walletPublicKey *ecdsa.PublicKey) ([32]byte, error) { + x, err := byteutils.LeftPadTo32Bytes(walletPublicKey.X.Bytes()) + if err != nil { + return [32]byte{}, fmt.Errorf("cannot encode wallet x-only key: [%w]", err) + } + + var result [32]byte + copy(result[:], x) + + return result, nil +} diff --git a/pkg/tbtc/tbtc.go b/pkg/tbtc/tbtc.go index 35872bf415..3e48edd808 100644 --- a/pkg/tbtc/tbtc.go +++ b/pkg/tbtc/tbtc.go @@ -72,6 +72,15 @@ type Config struct { // execution is unavailable. `ffi` requires native execution and does not // allow fallback. FrostSigningBackend string + // DisableLegacyECDSA skips legacy ECDSA wallet DKG handling and pre-params + // generation. This is intended for FROST-only deployments where wallet + // creation and signing are handled by the FROST registry and signer. + DisableLegacyECDSA bool + // DisableLegacySortitionPoolMonitoring skips monitoring and auto-joining + // the legacy ECDSA sortition pool. This is intended for FROST-only + // deployments where operators are authorized through FrostAllowlist and no + // longer have TokenStaking-backed ECDSA operator state. + DisableLegacySortitionPoolMonitoring bool } // Initialize kicks off the TBTC by initializing internal state, ensuring @@ -128,6 +137,10 @@ func Initialize( "tbtc", map[string]clientinfo.Source{ "pre_params_count": func() float64 { + if node.dkgExecutor == nil { + return 0 + } + return float64(node.dkgExecutor.preParamsCount()) }, }, @@ -158,147 +171,155 @@ func Initialize( ) } - err = sortition.MonitorPool( - ctx, - logger, - chain, - sortition.DefaultStatusCheckTick, - sortition.NewConjunctionPolicy( - sortition.NewBetaOperatorPolicy(chain, logger), - &enoughPreParamsInPoolPolicy{ - node: node, - config: config, - }, - ), - ) - if err != nil { - return fmt.Errorf( - "could not set up sortition pool monitoring: [%v]", - err, + if shouldMonitorLegacySortitionPool(config) { + err = sortition.MonitorPool( + ctx, + logger, + chain, + sortition.DefaultStatusCheckTick, + sortition.NewConjunctionPolicy( + sortition.NewBetaOperatorPolicy(chain, logger), + &enoughPreParamsInPoolPolicy{ + node: node, + config: config, + }, + ), ) + if err != nil { + return fmt.Errorf( + "could not set up sortition pool monitoring: [%v]", + err, + ) + } + } else { + logger.Infof("legacy ECDSA sortition pool monitoring disabled") } - _ = chain.OnDKGStarted(func(event *DKGStartedEvent) { - go func() { - if ok := deduplicator.notifyDKGStarted( - event.Seed, - ); !ok { - logger.Infof( - "DKG started event with seed [0x%x] has been "+ - "already processed", + if shouldRunLegacyECDSA(config) { + _ = chain.OnDKGStarted(func(event *DKGStartedEvent) { + go func() { + if ok := deduplicator.notifyDKGStarted( event.Seed, - ) - return - } - - confirmationBlock := event.BlockNumber + dkgStartedConfirmationBlocks - - logger.Infof( - "observed DKG started event with seed [0x%x] and "+ - "starting block [%v]; waiting for block [%v] to confirm", - event.Seed, - event.BlockNumber, - confirmationBlock, - ) + ); !ok { + logger.Infof( + "DKG started event with seed [0x%x] has been "+ + "already processed", + event.Seed, + ) + return + } - err := node.waitForBlockHeight(ctx, confirmationBlock) - if err != nil { - logger.Errorf("failed to confirm DKG started event: [%v]", err) - return - } + confirmationBlock := event.BlockNumber + dkgStartedConfirmationBlocks - dkgState, err := chain.GetDKGState() - if err != nil { - logger.Errorf("failed to check DKG state: [%v]", err) - return - } - - if dkgState == AwaitingResult { - // Fetch all past DKG started events starting from one - // confirmation period before the original event's block. - // If there was a chain reorg, the event we received could be - // moved to a block with a lower number than the one - // we received. - pastEvents, err := chain.PastDKGStartedEvents( - &DKGStartedEventFilter{ - StartBlock: event.BlockNumber - dkgStartedConfirmationBlocks, - }, + logger.Infof( + "observed DKG started event with seed [0x%x] and "+ + "starting block [%v]; waiting for block [%v] to confirm", + event.Seed, + event.BlockNumber, + confirmationBlock, ) + + err := node.waitForBlockHeight(ctx, confirmationBlock) if err != nil { - logger.Errorf("failed to get past DKG started events: [%v]", err) + logger.Errorf("failed to confirm DKG started event: [%v]", err) return } - // Should not happen but just in case. - if len(pastEvents) == 0 { - logger.Errorf("no past DKG started events") + dkgState, err := chain.GetDKGState() + if err != nil { + logger.Errorf("failed to check DKG state: [%v]", err) return } - lastEvent := pastEvents[len(pastEvents)-1] - - logger.Infof( - "DKG started with seed [0x%x] at block [%v]", - lastEvent.Seed, - lastEvent.BlockNumber, - ) + if dkgState == AwaitingResult { + // Fetch all past DKG started events starting from one + // confirmation period before the original event's block. + // If there was a chain reorg, the event we received could be + // moved to a block with a lower number than the one + // we received. + pastEvents, err := chain.PastDKGStartedEvents( + &DKGStartedEventFilter{ + StartBlock: event.BlockNumber - dkgStartedConfirmationBlocks, + }, + ) + if err != nil { + logger.Errorf("failed to get past DKG started events: [%v]", err) + return + } + + // Should not happen but just in case. + if len(pastEvents) == 0 { + logger.Errorf("no past DKG started events") + return + } + + lastEvent := pastEvents[len(pastEvents)-1] + + logger.Infof( + "DKG started with seed [0x%x] at block [%v]", + lastEvent.Seed, + lastEvent.BlockNumber, + ) + + // The off-chain protocol should be started as close as possible + // to the current block or even further. Starting the off-chain + // protocol with a past block will likely cause a failure of the + // first attempt as the start block is used to synchronize + // the announcements and the state machine. Here we ensure + // a proper start point by delaying the execution by the + // confirmation period length. + node.joinDKGIfEligible( + lastEvent.Seed, + lastEvent.BlockNumber, + dkgStartedConfirmationBlocks, + ) + } else { + logger.Infof( + "DKG started event with seed [0x%x] and starting "+ + "block [%v] was not confirmed", + event.Seed, + event.BlockNumber, + ) + } + }() + }) - // The off-chain protocol should be started as close as possible - // to the current block or even further. Starting the off-chain - // protocol with a past block will likely cause a failure of the - // first attempt as the start block is used to synchronize - // the announcements and the state machine. Here we ensure - // a proper start point by delaying the execution by the - // confirmation period length. - node.joinDKGIfEligible( - lastEvent.Seed, - lastEvent.BlockNumber, - dkgStartedConfirmationBlocks, - ) - } else { - logger.Infof( - "DKG started event with seed [0x%x] and starting "+ - "block [%v] was not confirmed", + _ = chain.OnDKGResultSubmitted(func(event *DKGResultSubmittedEvent) { + go func() { + if ok := deduplicator.notifyDKGResultSubmitted( event.Seed, + event.ResultHash, event.BlockNumber, - ) - } - }() - }) + ); !ok { + logger.Warnf( + "Result with hash [0x%x] for DKG with seed [0x%x] "+ + "and starting block [%v] has been already processed", + event.ResultHash, + event.Seed, + event.BlockNumber, + ) + return + } - _ = chain.OnDKGResultSubmitted(func(event *DKGResultSubmittedEvent) { - go func() { - if ok := deduplicator.notifyDKGResultSubmitted( - event.Seed, - event.ResultHash, - event.BlockNumber, - ); !ok { - logger.Warnf( + logger.Infof( "Result with hash [0x%x] for DKG with seed [0x%x] "+ - "and starting block [%v] has been already processed", + "submitted at block [%v]", event.ResultHash, event.Seed, event.BlockNumber, ) - return - } - logger.Infof( - "Result with hash [0x%x] for DKG with seed [0x%x] "+ - "submitted at block [%v]", - event.ResultHash, - event.Seed, - event.BlockNumber, - ) - - node.validateDKG( - event.Seed, - event.BlockNumber, - event.Result, - event.ResultHash, - ) - }() - }) + node.validateDKG( + event.Seed, + event.BlockNumber, + event.Result, + event.ResultHash, + ) + }() + }) + } else { + logger.Infof("legacy ECDSA wallet DKG disabled") + } _ = chain.OnWalletClosed(func(event *WalletClosedEvent) { go func() { @@ -337,6 +358,15 @@ func Initialize( return nil } +func shouldMonitorLegacySortitionPool(config Config) bool { + return shouldRunLegacyECDSA(config) && + !config.DisableLegacySortitionPoolMonitoring +} + +func shouldRunLegacyECDSA(config Config) bool { + return !config.DisableLegacyECDSA +} + // enoughPreParamsInPoolPolicy is a policy that enforces the sufficient size // of the DKG pre-parameters pool before joining the sortition pool. type enoughPreParamsInPoolPolicy struct { diff --git a/pkg/tbtc/tbtc_test.go b/pkg/tbtc/tbtc_test.go new file mode 100644 index 0000000000..f5f6878896 --- /dev/null +++ b/pkg/tbtc/tbtc_test.go @@ -0,0 +1,31 @@ +package tbtc + +import "testing" + +func TestShouldMonitorLegacySortitionPool(t *testing.T) { + if !shouldMonitorLegacySortitionPool(Config{}) { + t.Fatal("expected legacy sortition pool monitoring to be enabled by default") + } + + if shouldMonitorLegacySortitionPool(Config{ + DisableLegacySortitionPoolMonitoring: true, + }) { + t.Fatal("expected legacy sortition pool monitoring to be disabled") + } + + if shouldMonitorLegacySortitionPool(Config{ + DisableLegacyECDSA: true, + }) { + t.Fatal("expected FROST-only mode to disable legacy sortition pool monitoring") + } +} + +func TestShouldRunLegacyECDSA(t *testing.T) { + if !shouldRunLegacyECDSA(Config{}) { + t.Fatal("expected legacy ECDSA to run by default") + } + + if shouldRunLegacyECDSA(Config{DisableLegacyECDSA: true}) { + t.Fatal("expected legacy ECDSA to be disabled") + } +} diff --git a/pkg/tbtc/wallet.go b/pkg/tbtc/wallet.go index 8e24cf7100..5208c89b84 100644 --- a/pkg/tbtc/wallet.go +++ b/pkg/tbtc/wallet.go @@ -292,6 +292,15 @@ type walletSigningExecutor interface { ) ([]*frost.Signature, error) } +type taprootTweakedWalletSigningExecutor interface { + signBatchWithTaprootMerkleRoots( + ctx context.Context, + messages []*big.Int, + taprootMerkleRoots []*[32]byte, + startBlock uint64, + ) ([]*frost.Signature, error) +} + // walletTransactionExecutor is a component allowing to sign and broadcast // wallet Bitcoin transactions. type walletTransactionExecutor struct { @@ -400,11 +409,29 @@ func (wte *walletTransactionExecutor) signTransaction( ) defer cancelSigningCtx() - signatures, err := wte.signingExecutor.signBatch( - signingCtx, - sigHashes, - signingStartBlock, - ) + var signatures []*frost.Signature + taprootMerkleRoots := unsignedTx.TaprootKeyPathInputMerkleRoots() + if hasTaprootMerkleRoots(taprootMerkleRoots) { + tweakedSigningExecutor, ok := wte.signingExecutor.(taprootTweakedWalletSigningExecutor) + if !ok { + return nil, fmt.Errorf( + "taproot tweaked signing requires signer support", + ) + } + + signatures, err = tweakedSigningExecutor.signBatchWithTaprootMerkleRoots( + signingCtx, + sigHashes, + taprootMerkleRoots, + signingStartBlock, + ) + } else { + signatures, err = wte.signingExecutor.signBatch( + signingCtx, + sigHashes, + signingStartBlock, + ) + } if err != nil { return nil, fmt.Errorf( "error while signing transaction's sig hashes: [%v]", @@ -461,6 +488,16 @@ func (wte *walletTransactionExecutor) signTransaction( return tx, nil } +func hasTaprootMerkleRoots(taprootMerkleRoots []*[32]byte) bool { + for _, merkleRoot := range taprootMerkleRoots { + if merkleRoot != nil { + return true + } + } + + return false +} + func nativeBuildTaprootTxSigningSubstitutionEnabled() bool { switch strings.ToLower( strings.TrimSpace( @@ -906,6 +943,48 @@ func DetermineWalletMainUtxo( walletPublicKeyHash [20]byte, bridgeChain BridgeChain, btcChain bitcoin.Chain, +) (*bitcoin.UnspentTransactionOutput, error) { + walletScripts, err := legacyWalletPublicKeyScripts(walletPublicKeyHash) + if err != nil { + return nil, err + } + + return determineWalletMainUtxo( + walletPublicKeyHash, + walletScripts, + bridgeChain, + btcChain, + ) +} + +// DetermineWalletMainUtxoForPublicKey determines the plain-text wallet main +// UTXO currently registered in the Bridge on-chain contract. Unlike +// DetermineWalletMainUtxo, this variant can discover Taproot wallet outputs. +func DetermineWalletMainUtxoForPublicKey( + walletPublicKey *ecdsa.PublicKey, + bridgeChain BridgeChain, + btcChain bitcoin.Chain, +) (*bitcoin.UnspentTransactionOutput, error) { + walletPublicKeyHash := bitcoin.PublicKeyHash(walletPublicKey) + + walletScripts, err := walletPublicKeyScripts(walletPublicKey) + if err != nil { + return nil, err + } + + return determineWalletMainUtxo( + walletPublicKeyHash, + walletScripts, + bridgeChain, + btcChain, + ) +} + +func determineWalletMainUtxo( + walletPublicKeyHash [20]byte, + walletScripts []bitcoin.Script, + bridgeChain BridgeChain, + btcChain bitcoin.Chain, ) (*bitcoin.UnspentTransactionOutput, error) { walletChainData, err := bridgeChain.GetWallet(walletPublicKeyHash) if err != nil { @@ -930,20 +1009,15 @@ func DetermineWalletMainUtxo( // fetch full transaction data (time-consuming calls) starting from // the most recent transactions as there is a high chance the main UTXO // comes from there. - txHashes, err := btcChain.GetTxHashesForPublicKeyHash(walletPublicKeyHash) + txHashes, err := getTxHashesForWalletScripts( + btcChain, + walletPublicKeyHash, + walletScripts, + ) if err != nil { return nil, fmt.Errorf("cannot get transactions history for wallet: [%v]", err) } - walletP2PKH, err := bitcoin.PayToPublicKeyHash(walletPublicKeyHash) - if err != nil { - return nil, fmt.Errorf("cannot construct P2PKH for wallet: [%v]", err) - } - walletP2WPKH, err := bitcoin.PayToWitnessPublicKeyHash(walletPublicKeyHash) - if err != nil { - return nil, fmt.Errorf("cannot construct P2WPKH for wallet: [%v]", err) - } - // Start iterating from the latest transaction as the chance it matches // the wallet main UTXO is the highest. for i := len(txHashes) - 1; i >= 0; i-- { @@ -962,8 +1036,7 @@ func DetermineWalletMainUtxo( // the wallet public key hash. for outputIndex, output := range transaction.Outputs { script := output.PublicKeyScript - matchesWallet := bytes.Equal(script, walletP2PKH) || - bytes.Equal(script, walletP2WPKH) + matchesWallet := scriptMatchesAny(script, walletScripts) // Once the right output is found, check whether their hash // matches the main UTXO hash stored on-chain. If so, this @@ -995,11 +1068,63 @@ func EnsureWalletSyncedBetweenChains( walletMainUtxo *bitcoin.UnspentTransactionOutput, bridgeChain BridgeChain, btcChain bitcoin.Chain, +) error { + walletScripts, err := legacyWalletPublicKeyScripts(walletPublicKeyHash) + if err != nil { + return err + } + + return ensureWalletSyncedBetweenChains( + walletPublicKeyHash, + walletScripts, + walletMainUtxo, + bridgeChain, + btcChain, + ) +} + +// EnsureWalletSyncedBetweenChainsForPublicKey makes sure all actions taken by +// the wallet on the Bitcoin chain are reflected in the host chain Bridge. +// Unlike EnsureWalletSyncedBetweenChains, this variant can discover Taproot +// wallet outputs. +func EnsureWalletSyncedBetweenChainsForPublicKey( + walletPublicKey *ecdsa.PublicKey, + walletMainUtxo *bitcoin.UnspentTransactionOutput, + bridgeChain BridgeChain, + btcChain bitcoin.Chain, +) error { + walletPublicKeyHash := bitcoin.PublicKeyHash(walletPublicKey) + + walletScripts, err := walletPublicKeyScripts(walletPublicKey) + if err != nil { + return err + } + + return ensureWalletSyncedBetweenChains( + walletPublicKeyHash, + walletScripts, + walletMainUtxo, + bridgeChain, + btcChain, + ) +} + +func ensureWalletSyncedBetweenChains( + walletPublicKeyHash [20]byte, + walletScripts []bitcoin.Script, + walletMainUtxo *bitcoin.UnspentTransactionOutput, + bridgeChain BridgeChain, + btcChain bitcoin.Chain, ) error { // Take UTXOs controlled by the wallet on Bitcoin chain. Those are outputs // coming from confirmed transactions, ready to be spent right now, and // not used as inputs of other (either confirmed or mempool) transactions. - confirmedUtxos, err := btcChain.GetUtxosForPublicKeyHash(walletPublicKeyHash) + confirmedUtxos, err := getUtxosForWalletScripts( + btcChain, + walletPublicKeyHash, + walletScripts, + true, + ) if err != nil { return fmt.Errorf("cannot get confirmed UTXOs: [%v]", err) } @@ -1046,7 +1171,12 @@ func EnsureWalletSyncedBetweenChains( // to the wallet address. We need to look at the confirmed and mempool // UTXOs and make sure there are no transactions produced by the wallet // there. - mempoolUtxos, err := btcChain.GetMempoolUtxosForPublicKeyHash(walletPublicKeyHash) + mempoolUtxos, err := getUtxosForWalletScripts( + btcChain, + walletPublicKeyHash, + walletScripts, + false, + ) if err != nil { return fmt.Errorf("cannot get mempool UTXOs: [%v]", err) } @@ -1153,6 +1283,100 @@ func EnsureWalletSyncedBetweenChains( } } +type walletPublicKeyScriptsChain interface { + GetTxHashesForPublicKeyScripts( + publicKeyScripts []bitcoin.Script, + ) ([]bitcoin.Hash, error) + GetUtxosForPublicKeyScripts( + publicKeyScripts []bitcoin.Script, + ) ([]*bitcoin.UnspentTransactionOutput, error) + GetMempoolUtxosForPublicKeyScripts( + publicKeyScripts []bitcoin.Script, + ) ([]*bitcoin.UnspentTransactionOutput, error) +} + +func legacyWalletPublicKeyScripts( + walletPublicKeyHash [20]byte, +) ([]bitcoin.Script, error) { + walletP2PKH, err := bitcoin.PayToPublicKeyHash(walletPublicKeyHash) + if err != nil { + return nil, fmt.Errorf("cannot construct P2PKH for wallet: [%v]", err) + } + + walletP2WPKH, err := bitcoin.PayToWitnessPublicKeyHash(walletPublicKeyHash) + if err != nil { + return nil, fmt.Errorf("cannot construct P2WPKH for wallet: [%v]", err) + } + + return []bitcoin.Script{walletP2PKH, walletP2WPKH}, nil +} + +func walletPublicKeyScripts( + walletPublicKey *ecdsa.PublicKey, +) ([]bitcoin.Script, error) { + walletPublicKeyHash := bitcoin.PublicKeyHash(walletPublicKey) + + walletScripts, err := legacyWalletPublicKeyScripts(walletPublicKeyHash) + if err != nil { + return nil, err + } + + xOnlyPublicKey, err := walletXOnlyPublicKey(walletPublicKey) + if err != nil { + return nil, err + } + + walletP2TR, err := bitcoin.PayToTaproot(xOnlyPublicKey) + if err != nil { + return nil, fmt.Errorf("cannot construct P2TR for wallet: [%v]", err) + } + + return append(walletScripts, walletP2TR), nil +} + +func getTxHashesForWalletScripts( + btcChain bitcoin.Chain, + walletPublicKeyHash [20]byte, + walletScripts []bitcoin.Script, +) ([]bitcoin.Hash, error) { + if scriptChain, ok := btcChain.(walletPublicKeyScriptsChain); ok { + return scriptChain.GetTxHashesForPublicKeyScripts(walletScripts) + } + + return btcChain.GetTxHashesForPublicKeyHash(walletPublicKeyHash) +} + +func getUtxosForWalletScripts( + btcChain bitcoin.Chain, + walletPublicKeyHash [20]byte, + walletScripts []bitcoin.Script, + confirmed bool, +) ([]*bitcoin.UnspentTransactionOutput, error) { + if scriptChain, ok := btcChain.(walletPublicKeyScriptsChain); ok { + if confirmed { + return scriptChain.GetUtxosForPublicKeyScripts(walletScripts) + } + + return scriptChain.GetMempoolUtxosForPublicKeyScripts(walletScripts) + } + + if confirmed { + return btcChain.GetUtxosForPublicKeyHash(walletPublicKeyHash) + } + + return btcChain.GetMempoolUtxosForPublicKeyHash(walletPublicKeyHash) +} + +func scriptMatchesAny(script bitcoin.Script, scripts []bitcoin.Script) bool { + for _, candidate := range scripts { + if bytes.Equal(script, candidate) { + return true + } + } + + return false +} + // signer represents a threshold signer of a tBTC wallet. A signer holds // a wallet tECDSA private key share and is able to participate in the // signing process. diff --git a/pkg/tbtc/wallet_id_from_signer_frost_native.go b/pkg/tbtc/wallet_id_from_signer_frost_native.go index a8009869a7..8f0c8cb5e3 100644 --- a/pkg/tbtc/wallet_id_from_signer_frost_native.go +++ b/pkg/tbtc/wallet_id_from_signer_frost_native.go @@ -34,11 +34,12 @@ func frostWalletIDFromSigner(signer *signer) ([32]byte, bool, error) { return [32]byte{}, false, nil } - if material.Format != frostsigning.NativeSignerMaterialFormatFrostUniFFIV2 { + if material.Format != frostsigning.NativeSignerMaterialFormatFrostUniFFIV2 && + material.Format != frostsigning.NativeSignerMaterialFormatFrostTBTCSignerV1 { return [32]byte{}, false, nil } - xOnlyOutputKey, err := frostsigning.ExtractDkgGroupPublicKeyFromMaterial( + xOnlyOutputKey, err := frostsigning.ExtractTaprootOutputKeyFromMaterial( material, ) if err != nil { diff --git a/pkg/tbtc/wallet_sign_transaction_build_taproot_tx_test.go b/pkg/tbtc/wallet_sign_transaction_build_taproot_tx_test.go index dd6e081951..abec9253f4 100644 --- a/pkg/tbtc/wallet_sign_transaction_build_taproot_tx_test.go +++ b/pkg/tbtc/wallet_sign_transaction_build_taproot_tx_test.go @@ -1023,6 +1023,160 @@ func TestWalletTransactionExecutor_SignTransaction_AppliesTaprootKeyPathSignatur } } +func TestWalletTransactionExecutor_SignTransaction_AppliesTweakedTaprootKeyPathSignatures( + t *testing.T, +) { + originalBuildTaprootTxViaNativeSignerFn := buildTaprootTxViaNativeSignerFn + t.Cleanup(func() { + buildTaprootTxViaNativeSignerFn = originalBuildTaprootTxViaNativeSignerFn + }) + buildTaprootTxViaNativeSignerFn = func( + unsignedTx *bitcoin.TransactionBuilder, + ) (string, error) { + return "", nil + } + + internalPrivateKeyBytes := mustDecodeHex( + t, + "0101010101010101010101010101010101010101010101010101010101010101", + ) + _, internalPublicKey := btcec2.PrivKeyFromBytes(internalPrivateKeyBytes) + + var internalKey [32]byte + copy(internalKey[:], schnorr.SerializePubKey(internalPublicKey)) + + refundLeaf := bitcoin.Script(mustDecodeHex( + t, + "76a9140102030405060708090a0b0c0d0e0f101112131488ac", + )) + merkleRoot, err := bitcoin.TaprootLeafHash(refundLeaf) + if err != nil { + t.Fatalf("cannot compute taproot leaf hash: [%v]", err) + } + + taprootOutputKey, err := bitcoin.TaprootOutputKey(internalKey, &merkleRoot) + if err != nil { + t.Fatalf("cannot derive taproot output key: [%v]", err) + } + + inputScript, err := bitcoin.PayToTaproot(taprootOutputKey) + if err != nil { + t.Fatalf("cannot create taproot input script: [%v]", err) + } + + var outputPublicKeyHash [20]byte + copy( + outputPublicKeyHash[:], + mustDecodeHex(t, "0202020202020202020202020202020202020202"), + ) + outputScript, err := bitcoin.PayToWitnessPublicKeyHash(outputPublicKeyHash) + if err != nil { + t.Fatalf("cannot create output script: [%v]", err) + } + + localBitcoinChain := newLocalBitcoinChain() + fundingTransaction := &bitcoin.Transaction{ + Version: 1, + Inputs: []*bitcoin.TransactionInput{ + { + Outpoint: &bitcoin.TransactionOutpoint{ + TransactionHash: bitcoin.Hash{0x10}, + OutputIndex: 0, + }, + SignatureScript: []byte{0x51}, + Sequence: 0xffffffff, + }, + }, + Outputs: []*bitcoin.TransactionOutput{ + { + Value: 100000, + PublicKeyScript: inputScript, + }, + }, + Locktime: 0, + } + if err := localBitcoinChain.BroadcastTransaction(fundingTransaction); err != nil { + t.Fatalf("cannot broadcast funding transaction: [%v]", err) + } + + unsignedTx := bitcoin.NewTransactionBuilder(localBitcoinChain) + if err := unsignedTx.AddTaprootKeyPathInputWithMerkleRoot( + &bitcoin.UnspentTransactionOutput{ + Outpoint: &bitcoin.TransactionOutpoint{ + TransactionHash: fundingTransaction.Hash(), + OutputIndex: 0, + }, + Value: 100000, + }, + internalKey, + merkleRoot, + ); err != nil { + t.Fatalf("cannot add tweaked taproot input: [%v]", err) + } + unsignedTx.AddOutput(&bitcoin.TransactionOutput{ + Value: 90000, + PublicKeyScript: outputScript, + }) + + tweakedPrivateKeyBytes := mustDecodeHex( + t, + "6ba56a44ff544e35d38fd126659aa68b2c4677a7ebbf7464ad2e9d86c18e1149", + ) + tweakedPrivateKey, _ := btcec2.PrivKeyFromBytes(tweakedPrivateKeyBytes) + + signingExecutor := &taprootMerkleRootRecordingSchnorrSigningExecutor{ + privateKey: tweakedPrivateKey, + } + + wte := &walletTransactionExecutor{ + executingWallet: generateWallet(big.NewInt(111)), + signingExecutor: signingExecutor, + waitForBlockFn: func(ctx context.Context, block uint64) error { + return nil + }, + } + + tx, err := wte.signTransaction(&warningCaptureLogger{}, unsignedTx, 0, 0) + if err != nil { + t.Fatalf("unexpected signTransaction error: [%v]", err) + } + + if signingExecutor.signBatchCalled { + t.Fatal("ordinary signBatch must not be called for tweaked taproot input") + } + + if len(signingExecutor.taprootMerkleRoots) != 1 { + t.Fatalf( + "unexpected taproot merkle root count\nexpected: [%d]\nactual: [%d]", + 1, + len(signingExecutor.taprootMerkleRoots), + ) + } + if signingExecutor.taprootMerkleRoots[0] == nil { + t.Fatal("expected taproot merkle root") + } + if !bytes.Equal(signingExecutor.taprootMerkleRoots[0][:], merkleRoot[:]) { + t.Fatalf( + "unexpected taproot merkle root\nexpected: [%x]\nactual: [%x]", + merkleRoot, + *signingExecutor.taprootMerkleRoots[0], + ) + } + + if len(tx.Inputs) != 1 { + t.Fatalf("unexpected input count: [%d]", len(tx.Inputs)) + } + if len(tx.Inputs[0].Witness) != 1 { + t.Fatalf("unexpected taproot witness: [%x]", tx.Inputs[0].Witness) + } + if len(tx.Inputs[0].SignatureScript) != 0 { + t.Fatalf( + "unexpected signature script for taproot input: [%x]", + tx.Inputs[0].SignatureScript, + ) + } +} + func TestWalletTransactionExecutor_SignTransaction_RejectsMixedTaprootAndLegacyInputsBeforeSigning( t *testing.T, ) { @@ -1376,6 +1530,59 @@ func (dsseft *deterministicSchnorrSigningExecutorForTaproot) signBatch( return signatures, nil } +type taprootMerkleRootRecordingSchnorrSigningExecutor struct { + privateKey *btcec2.PrivateKey + signBatchCalled bool + taprootMerkleRoots []*[32]byte +} + +func (tmrrsse *taprootMerkleRootRecordingSchnorrSigningExecutor) signBatch( + ctx context.Context, + messages []*big.Int, + startBlock uint64, +) ([]*frost.Signature, error) { + tmrrsse.signBatchCalled = true + return nil, errors.New("unexpected signBatch invocation") +} + +func (tmrrsse *taprootMerkleRootRecordingSchnorrSigningExecutor) signBatchWithTaprootMerkleRoots( + ctx context.Context, + messages []*big.Int, + taprootMerkleRoots []*[32]byte, + startBlock uint64, +) ([]*frost.Signature, error) { + tmrrsse.taprootMerkleRoots = make([]*[32]byte, len(taprootMerkleRoots)) + for i, taprootMerkleRoot := range taprootMerkleRoots { + if taprootMerkleRoot == nil { + continue + } + + tmrrsse.taprootMerkleRoots[i] = new([32]byte) + copy(tmrrsse.taprootMerkleRoots[i][:], taprootMerkleRoot[:]) + } + + signatures := make([]*frost.Signature, 0, len(messages)) + + for _, message := range messages { + signature, err := schnorr.Sign( + tmrrsse.privateKey, + message.FillBytes(make([]byte, 32)), + ) + if err != nil { + return nil, err + } + + serialized := signature.Serialize() + frostSignature := &frost.Signature{} + copy(frostSignature.R[:], serialized[:32]) + copy(frostSignature.S[:], serialized[32:]) + + signatures = append(signatures, frostSignature) + } + + return signatures, nil +} + type unexpectedSigningExecutorForBuildTaprootTxError struct{} func (usefbte *unexpectedSigningExecutorForBuildTaprootTxError) signBatch( diff --git a/pkg/tbtcpg/chain.go b/pkg/tbtcpg/chain.go index 01e519c462..f313d8337b 100644 --- a/pkg/tbtcpg/chain.go +++ b/pkg/tbtcpg/chain.go @@ -104,6 +104,19 @@ type Chain interface { }, ) error + // ValidateTaprootDepositSweepProposal validates the given Taproot deposit + // sweep proposal against the chain. It requires some additional data about + // the deposits that must be fetched externally. Returns an error if the + // proposal is not valid or nil otherwise. + ValidateTaprootDepositSweepProposal( + walletPublicKeyHash [20]byte, + proposal *tbtc.DepositSweepProposal, + depositsExtraInfo []struct { + *tbtc.Deposit + FundingTx *bitcoin.Transaction + }, + ) error + // ValidateRedemptionProposal validates the given redemption proposal // against the chain. Returns an error if the proposal is not valid or // nil otherwise. diff --git a/pkg/tbtcpg/chain_test.go b/pkg/tbtcpg/chain_test.go index af56f9ffcf..7a0a40a4d7 100644 --- a/pkg/tbtcpg/chain_test.go +++ b/pkg/tbtcpg/chain_test.go @@ -75,6 +75,7 @@ type LocalChain struct { depositRequests map[[32]byte]*tbtc.DepositChainRequest pastDepositRevealedEvents map[[32]byte][]*tbtc.DepositRevealedEvent + pastTaprootDepositRevealedEvents map[[32]byte][]*tbtc.TaprootDepositRevealedEvent pastNewWalletRegisteredEvents map[[32]byte][]*tbtc.NewWalletRegisteredEvent depositParameters depositParameters depositSweepProposalValidations map[[32]byte]bool @@ -104,6 +105,7 @@ func NewLocalChain() *LocalChain { return &LocalChain{ depositRequests: make(map[[32]byte]*tbtc.DepositChainRequest), pastDepositRevealedEvents: make(map[[32]byte][]*tbtc.DepositRevealedEvent), + pastTaprootDepositRevealedEvents: make(map[[32]byte][]*tbtc.TaprootDepositRevealedEvent), pastNewWalletRegisteredEvents: make(map[[32]byte][]*tbtc.NewWalletRegisteredEvent), depositSweepProposalValidations: make(map[[32]byte]bool), pastRedemptionRequestedEvents: make(map[[32]byte][]*tbtc.RedemptionRequestedEvent), @@ -161,6 +163,45 @@ func (lc *LocalChain) AddPastDepositRevealedEvent( return nil } +func (lc *LocalChain) PastTaprootDepositRevealedEvents( + filter *tbtc.DepositRevealedEventFilter, +) ([]*tbtc.TaprootDepositRevealedEvent, error) { + lc.mutex.Lock() + defer lc.mutex.Unlock() + + eventsKey, err := buildPastDepositRevealedEventsKey(filter) + if err != nil { + return nil, err + } + + events, ok := lc.pastTaprootDepositRevealedEvents[eventsKey] + if !ok { + return []*tbtc.TaprootDepositRevealedEvent{}, nil + } + + return events, nil +} + +func (lc *LocalChain) AddPastTaprootDepositRevealedEvent( + filter *tbtc.DepositRevealedEventFilter, + event *tbtc.TaprootDepositRevealedEvent, +) error { + lc.mutex.Lock() + defer lc.mutex.Unlock() + + eventsKey, err := buildPastDepositRevealedEventsKey(filter) + if err != nil { + return err + } + + lc.pastTaprootDepositRevealedEvents[eventsKey] = append( + lc.pastTaprootDepositRevealedEvents[eventsKey], + event, + ) + + return nil +} + func buildPastDepositRevealedEventsKey( filter *tbtc.DepositRevealedEventFilter, ) ([32]byte, error) { @@ -615,6 +656,21 @@ func (lc *LocalChain) ValidateDepositSweepProposal( return nil } +func (lc *LocalChain) ValidateTaprootDepositSweepProposal( + walletPublicKeyHash [20]byte, + proposal *tbtc.DepositSweepProposal, + depositsExtraInfo []struct { + *tbtc.Deposit + FundingTx *bitcoin.Transaction + }, +) error { + return lc.ValidateDepositSweepProposal( + walletPublicKeyHash, + proposal, + depositsExtraInfo, + ) +} + func (lc *LocalChain) SetDepositSweepProposalValidationResult( walletPublicKeyHash [20]byte, proposal *tbtc.DepositSweepProposal, diff --git a/pkg/tbtcpg/deposit_sweep.go b/pkg/tbtcpg/deposit_sweep.go index 491e4411fa..72125db8e4 100644 --- a/pkg/tbtcpg/deposit_sweep.go +++ b/pkg/tbtcpg/deposit_sweep.go @@ -114,6 +114,7 @@ type Deposit struct { WalletPublicKeyHash [20]byte DepositKey string IsSwept bool + IsTaproot bool AmountBtc float64 Confirmations uint Vault *chain.Address @@ -147,7 +148,7 @@ func FindDeposits( // deposit-revealed events are queried. func findDeposits( fnLogger log.StandardLogger, - chain Chain, + hostChain Chain, btcChain bitcoin.Chain, walletPublicKeyHash [20]byte, maxNumberOfDeposits int, @@ -157,7 +158,7 @@ func findDeposits( ) ([]*Deposit, error) { fnLogger.Infof("reading revealed deposits from chain") - depositMinAgeSeconds, err := chain.GetDepositMinAge() + depositMinAgeSeconds, err := hostChain.GetDepositMinAge() if err != nil { return nil, fmt.Errorf( "failed to get deposit minimum age: [%w]", @@ -173,7 +174,7 @@ func findDeposits( filter.WalletPublicKeyHash = [][20]byte{walletPublicKeyHash} } - depositRevealedEvents, err := chain.PastDepositRevealedEvents(filter) + depositRevealedEvents, err := hostChain.PastDepositRevealedEvents(filter) if err != nil { return []*Deposit{}, fmt.Errorf( "failed to get past deposit revealed events: [%w]", @@ -181,16 +182,73 @@ func findDeposits( ) } - fnLogger.Infof("found [%d] DepositRevealed events", len(depositRevealedEvents)) + taprootDepositRevealedEvents, err := hostChain.PastTaprootDepositRevealedEvents(filter) + if err != nil { + return []*Deposit{}, fmt.Errorf( + "failed to get past Taproot deposit revealed events: [%w]", + err, + ) + } + + fnLogger.Infof( + "found [%d] DepositRevealed events and [%d] TaprootDepositRevealed events", + len(depositRevealedEvents), + len(taprootDepositRevealedEvents), + ) + + type revealedDepositEvent struct { + FundingTxHash bitcoin.Hash + FundingOutputIndex uint32 + WalletPublicKeyHash [20]byte + Amount uint64 + Vault *chain.Address + BlockNumber uint64 + IsTaproot bool + } + + revealedDepositEvents := make( + []*revealedDepositEvent, + 0, + len(depositRevealedEvents)+len(taprootDepositRevealedEvents), + ) + + for _, event := range depositRevealedEvents { + revealedDepositEvents = append( + revealedDepositEvents, + &revealedDepositEvent{ + FundingTxHash: event.FundingTxHash, + FundingOutputIndex: event.FundingOutputIndex, + WalletPublicKeyHash: event.WalletPublicKeyHash, + Amount: event.Amount, + Vault: event.Vault, + BlockNumber: event.BlockNumber, + }, + ) + } + + for _, event := range taprootDepositRevealedEvents { + revealedDepositEvents = append( + revealedDepositEvents, + &revealedDepositEvent{ + FundingTxHash: event.FundingTxHash, + FundingOutputIndex: event.FundingOutputIndex, + WalletPublicKeyHash: event.WalletPublicKeyHash, + Amount: event.Amount, + Vault: event.Vault, + BlockNumber: event.BlockNumber, + IsTaproot: true, + }, + ) + } // Take the oldest first - sort.SliceStable(depositRevealedEvents, func(i, j int) bool { - return depositRevealedEvents[i].BlockNumber < depositRevealedEvents[j].BlockNumber + sort.SliceStable(revealedDepositEvents, func(i, j int) bool { + return revealedDepositEvents[i].BlockNumber < revealedDepositEvents[j].BlockNumber }) fnLogger.Infof("getting deposits details") - resultSliceCapacity := len(depositRevealedEvents) + resultSliceCapacity := len(revealedDepositEvents) if maxNumberOfDeposits > 0 { resultSliceCapacity = maxNumberOfDeposits } @@ -199,17 +257,17 @@ func findDeposits( timeNow := time.Now() result := make([]*Deposit, 0, resultSliceCapacity) - for _, event := range depositRevealedEvents { + for _, event := range revealedDepositEvents { if len(result) == cap(result) { break } - depositKey := chain.BuildDepositKey(event.FundingTxHash, event.FundingOutputIndex) + depositKey := hostChain.BuildDepositKey(event.FundingTxHash, event.FundingOutputIndex) depositKeyStr := depositKey.Text(16) fnLogger.Debugf("getting details of deposit [%s]", depositKeyStr) - depositRequest, found, err := chain.GetDepositRequest( + depositRequest, found, err := hostChain.GetDepositRequest( event.FundingTxHash, event.FundingOutputIndex, ) @@ -268,6 +326,7 @@ func findDeposits( WalletPublicKeyHash: event.WalletPublicKeyHash, DepositKey: hexutils.Encode(depositKey.Bytes()), IsSwept: isSwept, + IsTaproot: event.IsTaproot, AmountBtc: convertSatToBtc(float64(depositRequest.Amount)), Confirmations: confirmations, Vault: depositRequest.Vault, @@ -351,6 +410,10 @@ func (dst *DepositSweepTask) FindDepositsToSweep( for _, deposit := range unsweptDeposits { var key string var label string + scriptType := "legacy" + if deposit.IsTaproot { + scriptType = "taproot" + } if deposit.Vault == nil { key = "" @@ -359,6 +422,8 @@ func (dst *DepositSweepTask) FindDepositsToSweep( key = strings.ToLower(string(*deposit.Vault)) label = string(*deposit.Vault) } + key = fmt.Sprintf("%s:%s", scriptType, key) + label = fmt.Sprintf("%s, %s", label, scriptType) g, exists := groups[key] if !exists { @@ -413,13 +478,15 @@ func (dst *DepositSweepTask) FindDepositsToSweep( // different vault, making it eligible for a future sweep. // The Warn-level log below flags these deposits for operator // awareness and manual follow-up. - if nilGroup, ok := groups[""]; ok { - for _, deposit := range nilGroup.deposits { - taskLogger.Warnf( - "vault=0x0 deposit [%s] with wallet PKH [0x%x] requires manual follow-up", - deposit.DepositKey, - deposit.WalletPublicKeyHash, - ) + for _, nilGroupKey := range []string{"legacy:", "taproot:"} { + if nilGroup, ok := groups[nilGroupKey]; ok { + for _, deposit := range nilGroup.deposits { + taskLogger.Warnf( + "vault=0x0 deposit [%s] with wallet PKH [0x%x] requires manual follow-up", + deposit.DepositKey, + deposit.WalletPublicKeyHash, + ) + } } } } diff --git a/pkg/tbtcpg/internal/test/marshaling.go b/pkg/tbtcpg/internal/test/marshaling.go index 2dd72dbaa0..b44955e5d2 100644 --- a/pkg/tbtcpg/internal/test/marshaling.go +++ b/pkg/tbtcpg/internal/test/marshaling.go @@ -3,14 +3,15 @@ package test import ( "encoding/hex" "encoding/json" + "errors" "fmt" - "github.com/keep-network/keep-core/pkg/tbtcpg" "math/big" "time" "github.com/keep-network/keep-core/internal/hexutils" "github.com/keep-network/keep-core/pkg/bitcoin" "github.com/keep-network/keep-core/pkg/tbtc" + "github.com/keep-network/keep-core/pkg/tbtcpg" ) // UnmarshalJSON implements a custom JSON unmarshaling logic to produce a @@ -273,7 +274,7 @@ func (psts *ProposeSweepTestScenario) UnmarshalJSON(data []byte) error { // Unmarshal expected error if len(unmarshaled.ExpectedErr) > 0 { - psts.ExpectedErr = fmt.Errorf(unmarshaled.ExpectedErr) + psts.ExpectedErr = errors.New(unmarshaled.ExpectedErr) } return nil