diff --git a/pkg/tbtc/gen/pb/message.pb.go b/pkg/tbtc/gen/pb/message.pb.go index 82068dd9a3..03a02f70ee 100644 --- a/pkg/tbtc/gen/pb/message.pb.go +++ b/pkg/tbtc/gen/pb/message.pb.go @@ -395,9 +395,8 @@ type MovingFundsProposal struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - WalletPublicKeyHash []byte `protobuf:"bytes,1,opt,name=walletPublicKeyHash,proto3" json:"walletPublicKeyHash,omitempty"` - TargetWallets [][]byte `protobuf:"bytes,2,rep,name=targetWallets,proto3" json:"targetWallets,omitempty"` - MovingFundsTxFee []byte `protobuf:"bytes,3,opt,name=movingFundsTxFee,proto3" json:"movingFundsTxFee,omitempty"` + TargetWallets [][]byte `protobuf:"bytes,1,rep,name=targetWallets,proto3" json:"targetWallets,omitempty"` + MovingFundsTxFee []byte `protobuf:"bytes,2,opt,name=movingFundsTxFee,proto3" json:"movingFundsTxFee,omitempty"` } func (x *MovingFundsProposal) Reset() { @@ -432,13 +431,6 @@ func (*MovingFundsProposal) Descriptor() ([]byte, []int) { return file_pkg_tbtc_gen_pb_message_proto_rawDescGZIP(), []int{6} } -func (x *MovingFundsProposal) GetWalletPublicKeyHash() []byte { - if x != nil { - return x.WalletPublicKeyHash - } - return nil -} - func (x *MovingFundsProposal) GetTargetWallets() [][]byte { if x != nil { return x.TargetWallets @@ -570,17 +562,14 @@ var file_pkg_tbtc_gen_pb_message_proto_rawDesc = []byte{ 0x75, 0x74, 0x53, 0x63, 0x72, 0x69, 0x70, 0x74, 0x73, 0x12, 0x28, 0x0a, 0x0f, 0x72, 0x65, 0x64, 0x65, 0x6d, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x78, 0x46, 0x65, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x0f, 0x72, 0x65, 0x64, 0x65, 0x6d, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x78, - 0x46, 0x65, 0x65, 0x22, 0x99, 0x01, 0x0a, 0x13, 0x4d, 0x6f, 0x76, 0x69, 0x6e, 0x67, 0x46, 0x75, - 0x6e, 0x64, 0x73, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x12, 0x30, 0x0a, 0x13, 0x77, - 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x48, 0x61, - 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x13, 0x77, 0x61, 0x6c, 0x6c, 0x65, 0x74, - 0x50, 0x75, 0x62, 0x6c, 0x69, 0x63, 0x4b, 0x65, 0x79, 0x48, 0x61, 0x73, 0x68, 0x12, 0x24, 0x0a, - 0x0d, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x73, 0x18, 0x02, - 0x20, 0x03, 0x28, 0x0c, 0x52, 0x0d, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x57, 0x61, 0x6c, 0x6c, - 0x65, 0x74, 0x73, 0x12, 0x2a, 0x0a, 0x10, 0x6d, 0x6f, 0x76, 0x69, 0x6e, 0x67, 0x46, 0x75, 0x6e, - 0x64, 0x73, 0x54, 0x78, 0x46, 0x65, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x10, 0x6d, - 0x6f, 0x76, 0x69, 0x6e, 0x67, 0x46, 0x75, 0x6e, 0x64, 0x73, 0x54, 0x78, 0x46, 0x65, 0x65, 0x42, - 0x06, 0x5a, 0x04, 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x46, 0x65, 0x65, 0x22, 0x67, 0x0a, 0x13, 0x4d, 0x6f, 0x76, 0x69, 0x6e, 0x67, 0x46, 0x75, 0x6e, + 0x64, 0x73, 0x50, 0x72, 0x6f, 0x70, 0x6f, 0x73, 0x61, 0x6c, 0x12, 0x24, 0x0a, 0x0d, 0x74, 0x61, + 0x72, 0x67, 0x65, 0x74, 0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, + 0x0c, 0x52, 0x0d, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x57, 0x61, 0x6c, 0x6c, 0x65, 0x74, 0x73, + 0x12, 0x2a, 0x0a, 0x10, 0x6d, 0x6f, 0x76, 0x69, 0x6e, 0x67, 0x46, 0x75, 0x6e, 0x64, 0x73, 0x54, + 0x78, 0x46, 0x65, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x10, 0x6d, 0x6f, 0x76, 0x69, + 0x6e, 0x67, 0x46, 0x75, 0x6e, 0x64, 0x73, 0x54, 0x78, 0x46, 0x65, 0x65, 0x42, 0x06, 0x5a, 0x04, + 0x2e, 0x2f, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pkg/tbtc/gen/pb/message.proto b/pkg/tbtc/gen/pb/message.proto index beba80ea45..d8aa30357e 100644 --- a/pkg/tbtc/gen/pb/message.proto +++ b/pkg/tbtc/gen/pb/message.proto @@ -44,7 +44,6 @@ message RedemptionProposal { } message MovingFundsProposal { - bytes walletPublicKeyHash = 1; - repeated bytes targetWallets = 2; - bytes movingFundsTxFee = 3; + repeated bytes targetWallets = 1; + bytes movingFundsTxFee = 2; } diff --git a/pkg/tbtc/marshaling.go b/pkg/tbtc/marshaling.go index 6c970a1e37..9eea456447 100644 --- a/pkg/tbtc/marshaling.go +++ b/pkg/tbtc/marshaling.go @@ -409,9 +409,8 @@ func (mfp *MovingFundsProposal) Marshal() ([]byte, error) { return proto.Marshal( &pb.MovingFundsProposal{ - WalletPublicKeyHash: mfp.WalletPublicKeyHash[:], - TargetWallets: targetWallets, - MovingFundsTxFee: mfp.MovingFundsTxFee.Bytes(), + TargetWallets: targetWallets, + MovingFundsTxFee: mfp.MovingFundsTxFee.Bytes(), }) } @@ -422,8 +421,6 @@ func (mfp *MovingFundsProposal) Unmarshal(data []byte) error { return fmt.Errorf("failed to unmarshal MovingFundsProposal: [%v]", err) } - copy(mfp.WalletPublicKeyHash[:], pbMsg.WalletPublicKeyHash) - mfp.TargetWallets = make([][20]byte, len(pbMsg.TargetWallets)) for i, wallet := range pbMsg.TargetWallets { copy(mfp.TargetWallets[i][:], wallet) diff --git a/pkg/tbtc/marshaling_test.go b/pkg/tbtc/marshaling_test.go index c686f30a1c..e9fc678e9a 100644 --- a/pkg/tbtc/marshaling_test.go +++ b/pkg/tbtc/marshaling_test.go @@ -186,9 +186,6 @@ func TestCoordinationMessage_MarshalingRoundtrip(t *testing.T) { }, "with moving funds proposal": { proposal: &MovingFundsProposal{ - WalletPublicKeyHash: toByte20( - "da7c1fb602db1931a3b815563b6f6fae6a58f224", - ), TargetWallets: [][20]byte{ toByte20("cb7d88a87c37aff0c1535fa4efe6f0a2406ea5e9"), toByte20("f87eb7ec3b15a3fdd7b57754d765694b3e0b4bf4"), diff --git a/pkg/tbtc/moving_funds.go b/pkg/tbtc/moving_funds.go index b2658de17c..0791647bdf 100644 --- a/pkg/tbtc/moving_funds.go +++ b/pkg/tbtc/moving_funds.go @@ -17,10 +17,8 @@ const ( // MovingFundsProposal represents a moving funds proposal issued by a wallet's // coordination leader. type MovingFundsProposal struct { - // TODO: Remove WalletPublicKeyHash field. - WalletPublicKeyHash [20]byte - TargetWallets [][20]byte - MovingFundsTxFee *big.Int + TargetWallets [][20]byte + MovingFundsTxFee *big.Int } func (mfp *MovingFundsProposal) ActionType() WalletActionType { diff --git a/pkg/tbtc/node.go b/pkg/tbtc/node.go index 5917dc3884..686207e26a 100644 --- a/pkg/tbtc/node.go +++ b/pkg/tbtc/node.go @@ -646,6 +646,12 @@ func (n *node) handleMovingFundsProposal( startBlock uint64, expiryBlock uint64, ) { + walletPublicKeyBytes, err := marshalPublicKey(wallet.publicKey) + if err != nil { + logger.Errorf("cannot marshal wallet public key: [%v]", err) + return + } + signingExecutor, ok, err := n.getSigningExecutor(wallet.publicKey) if err != nil { logger.Errorf("cannot get signing executor: [%v]", err) @@ -659,23 +665,16 @@ func (n *node) handleMovingFundsProposal( logger.Infof( "node does not control signers of wallet PKH [0x%x]; "+ "ignoring the received moving funds proposal", - proposal.WalletPublicKeyHash, + walletPublicKeyBytes, ) return } - walletPublicKeyBytes, err := marshalPublicKey(wallet.publicKey) - if err != nil { - logger.Errorf("cannot marshal wallet public key: [%v]", err) - return - } - logger.Infof( - "node controls signers of wallet PKH [0x%x]; "+ - "plain-text uncompressed public key of that wallet is [0x%x]; "+ - "starting orchestration of the moving funds action", - proposal.WalletPublicKeyHash, + "starting orchestration of the moving funds action for wallet [0x%x]; "+ + "20-byte public key hash of that wallet is [0x%x]", walletPublicKeyBytes, + bitcoin.PublicKeyHash(wallet.publicKey), ) walletActionLogger := logger.With( diff --git a/pkg/tbtcpg/moving_funds.go b/pkg/tbtcpg/moving_funds.go index 37e2402b5e..880fef7064 100644 --- a/pkg/tbtcpg/moving_funds.go +++ b/pkg/tbtcpg/moving_funds.go @@ -99,7 +99,6 @@ func (mft *MovingFundsTask) Run(request *tbtc.CoordinationProposalRequest) ( proposal, err := mft.ProposeMovingFunds( taskLogger, - walletPublicKeyHash, targetWallets, ) if err != nil { @@ -174,14 +173,13 @@ func (mft *MovingFundsTask) SubmitMovingFundsCommitment() ([][20]byte, error) { func (mft *MovingFundsTask) ProposeMovingFunds( taskLogger log.StandardLogger, - walletPublicKeyHash [20]byte, targetWallets [][20]byte, ) (*tbtc.MovingFundsProposal, error) { taskLogger.Infof("preparing a moving funds proposal") proposal := &tbtc.MovingFundsProposal{ - WalletPublicKeyHash: walletPublicKeyHash, - TargetWallets: targetWallets, + TargetWallets: targetWallets, + // TODO: Add fee } taskLogger.Infof("validating the moving funds proposal")