Skip to content

Commit

Permalink
Removed wallet public key hash from moving funds proposal
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaszslabon committed Jan 4, 2024
1 parent d943730 commit f8bdbef
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 51 deletions.
31 changes: 10 additions & 21 deletions pkg/tbtc/gen/pb/message.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions pkg/tbtc/gen/pb/message.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
7 changes: 2 additions & 5 deletions pkg/tbtc/marshaling.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
})
}

Expand All @@ -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)
Expand Down
3 changes: 0 additions & 3 deletions pkg/tbtc/marshaling_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
6 changes: 2 additions & 4 deletions pkg/tbtc/moving_funds.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
21 changes: 10 additions & 11 deletions pkg/tbtc/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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(
Expand Down
6 changes: 2 additions & 4 deletions pkg/tbtcpg/moving_funds.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ func (mft *MovingFundsTask) Run(request *tbtc.CoordinationProposalRequest) (

proposal, err := mft.ProposeMovingFunds(
taskLogger,
walletPublicKeyHash,
targetWallets,
)
if err != nil {
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit f8bdbef

Please sign in to comment.