@keep-network/tbtc-v2 0.1.1-dev.71 → 0.1.1-dev.74

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/artifacts/Bank.json +15 -15
  2. package/artifacts/Bridge.json +1 -1
  3. package/artifacts/DefaultProxyAdmin.json +5 -5
  4. package/artifacts/Deposit.json +10 -10
  5. package/artifacts/DepositSweep.json +13 -13
  6. package/artifacts/EcdsaDkgValidator.json +9 -9
  7. package/artifacts/EcdsaInactivity.json +8 -8
  8. package/artifacts/Fraud.json +23 -23
  9. package/artifacts/KeepRegistry.json +1 -1
  10. package/artifacts/KeepStake.json +2 -2
  11. package/artifacts/KeepToken.json +2 -2
  12. package/artifacts/KeepTokenStaking.json +1 -1
  13. package/artifacts/MovingFunds.json +31 -31
  14. package/artifacts/NuCypherStakingEscrow.json +1 -1
  15. package/artifacts/NuCypherToken.json +2 -2
  16. package/artifacts/RandomBeaconStub.json +5 -5
  17. package/artifacts/Redemption.json +22 -22
  18. package/artifacts/ReimbursementPool.json +5 -5
  19. package/artifacts/Relay.json +9 -9
  20. package/artifacts/SortitionPool.json +9 -9
  21. package/artifacts/T.json +2 -2
  22. package/artifacts/TBTC.json +17 -17
  23. package/artifacts/TBTCToken.json +15 -15
  24. package/artifacts/TokenStaking.json +1 -1
  25. package/artifacts/TokenholderGovernor.json +9 -9
  26. package/artifacts/TokenholderTimelock.json +8 -8
  27. package/artifacts/VendingMachine.json +18 -18
  28. package/artifacts/VendingMachineKeep.json +1 -1
  29. package/artifacts/VendingMachineNuCypher.json +1 -1
  30. package/artifacts/WalletRegistry.json +17 -17
  31. package/artifacts/WalletRegistry_Implementation.json +73 -73
  32. package/artifacts/WalletRegistry_Proxy.json +17 -17
  33. package/artifacts/Wallets.json +12 -12
  34. package/artifacts/solcInputs/3d39c8183330efd748c005f3c281bf2c.json +272 -0
  35. package/build/contracts/GovernanceUtils.sol/GovernanceUtils.dbg.json +1 -1
  36. package/build/contracts/GovernanceUtils.sol/GovernanceUtils.json +2 -2
  37. package/build/contracts/bank/Bank.sol/Bank.dbg.json +1 -1
  38. package/build/contracts/bank/Bank.sol/Bank.json +2 -2
  39. package/build/contracts/bridge/BitcoinTx.sol/BitcoinTx.dbg.json +1 -1
  40. package/build/contracts/bridge/BitcoinTx.sol/BitcoinTx.json +2 -2
  41. package/build/contracts/bridge/Bridge.sol/Bridge.dbg.json +1 -1
  42. package/build/contracts/bridge/Bridge.sol/Bridge.json +2 -2
  43. package/build/contracts/bridge/BridgeState.sol/BridgeState.dbg.json +1 -1
  44. package/build/contracts/bridge/BridgeState.sol/BridgeState.json +2 -2
  45. package/build/contracts/bridge/Deposit.sol/Deposit.dbg.json +1 -1
  46. package/build/contracts/bridge/Deposit.sol/Deposit.json +2 -2
  47. package/build/contracts/bridge/DepositSweep.sol/DepositSweep.dbg.json +1 -1
  48. package/build/contracts/bridge/DepositSweep.sol/DepositSweep.json +2 -2
  49. package/build/contracts/bridge/EcdsaLib.sol/EcdsaLib.dbg.json +1 -1
  50. package/build/contracts/bridge/Fraud.sol/Fraud.dbg.json +1 -1
  51. package/build/contracts/bridge/Fraud.sol/Fraud.json +2 -2
  52. package/build/contracts/bridge/Heartbeat.sol/Heartbeat.dbg.json +1 -1
  53. package/build/contracts/bridge/Heartbeat.sol/Heartbeat.json +2 -2
  54. package/build/contracts/bridge/IRelay.sol/IRelay.dbg.json +1 -1
  55. package/build/contracts/bridge/MovingFunds.sol/MovingFunds.dbg.json +1 -1
  56. package/build/contracts/bridge/MovingFunds.sol/MovingFunds.json +2 -2
  57. package/build/contracts/bridge/Redemption.sol/OutboundTx.dbg.json +1 -1
  58. package/build/contracts/bridge/Redemption.sol/OutboundTx.json +2 -2
  59. package/build/contracts/bridge/Redemption.sol/Redemption.dbg.json +1 -1
  60. package/build/contracts/bridge/Redemption.sol/Redemption.json +2 -2
  61. package/build/contracts/bridge/VendingMachine.sol/VendingMachine.dbg.json +1 -1
  62. package/build/contracts/bridge/VendingMachine.sol/VendingMachine.json +2 -2
  63. package/build/contracts/bridge/Wallets.sol/Wallets.dbg.json +1 -1
  64. package/build/contracts/bridge/Wallets.sol/Wallets.json +2 -2
  65. package/build/contracts/token/TBTC.sol/TBTC.dbg.json +1 -1
  66. package/build/contracts/token/TBTC.sol/TBTC.json +2 -2
  67. package/build/contracts/vault/DonationVault.sol/DonationVault.dbg.json +1 -1
  68. package/build/contracts/vault/DonationVault.sol/DonationVault.json +2 -2
  69. package/build/contracts/vault/IVault.sol/IVault.dbg.json +1 -1
  70. package/build/contracts/vault/TBTCVault.sol/TBTCVault.dbg.json +1 -1
  71. package/build/contracts/vault/TBTCVault.sol/TBTCVault.json +2 -2
  72. package/contracts/GovernanceUtils.sol +3 -3
  73. package/contracts/bank/Bank.sol +2 -2
  74. package/contracts/bridge/BitcoinTx.sol +7 -7
  75. package/contracts/bridge/Bridge.sol +193 -199
  76. package/contracts/bridge/BridgeState.sol +43 -44
  77. package/contracts/bridge/Deposit.sol +5 -7
  78. package/contracts/bridge/DepositSweep.sol +12 -12
  79. package/contracts/bridge/Fraud.sol +25 -25
  80. package/contracts/bridge/Heartbeat.sol +1 -1
  81. package/contracts/bridge/MovingFunds.sol +72 -72
  82. package/contracts/bridge/Redemption.sol +32 -39
  83. package/contracts/bridge/Wallets.sol +29 -29
  84. package/contracts/vault/DonationVault.sol +9 -9
  85. package/contracts/vault/IVault.sol +4 -4
  86. package/contracts/vault/TBTCVault.sol +14 -14
  87. package/package.json +3 -3
  88. package/artifacts/solcInputs/55619e5b15411ce6622d6da869c273a1.json +0 -269
@@ -124,42 +124,42 @@ library MovingFunds {
124
124
  /// Once all requirements are met, that function registers the
125
125
  /// target wallets commitment and opens the way for moving funds
126
126
  /// proof submission.
127
- /// @param walletPubKeyHash 20-byte public key hash of the source wallet
127
+ /// @param walletPubKeyHash 20-byte public key hash of the source wallet.
128
128
  /// @param walletMainUtxo Data of the source wallet's main UTXO, as
129
- /// currently known on the Ethereum chain
129
+ /// currently known on the Ethereum chain.
130
130
  /// @param walletMembersIDs Identifiers of the source wallet signing group
131
- /// members
131
+ /// members.
132
132
  /// @param walletMemberIndex Position of the caller in the source wallet
133
- /// signing group members list
133
+ /// signing group members list.
134
134
  /// @param targetWallets List of 20-byte public key hashes of the target
135
- /// wallets that the source wallet commits to move the funds to
135
+ /// wallets that the source wallet commits to move the funds to.
136
136
  /// @dev Requirements:
137
- /// - The source wallet must be in the MovingFunds state
138
- /// - The source wallet must not have pending redemption requests
139
- /// - The source wallet must not have pending moved funds sweep requests
140
- /// - The source wallet must not have submitted its commitment already
137
+ /// - The source wallet must be in the MovingFunds state,
138
+ /// - The source wallet must not have pending redemption requests,
139
+ /// - The source wallet must not have pending moved funds sweep requests,
140
+ /// - The source wallet must not have submitted its commitment already,
141
141
  /// - The expression `keccak256(abi.encode(walletMembersIDs))` must
142
142
  /// be exactly the same as the hash stored under `membersIdsHash`
143
143
  /// for the given source wallet in the ECDSA registry. Those IDs are
144
144
  /// not directly stored in the contract for gas efficiency purposes
145
145
  /// but they can be read from appropriate `DkgResultSubmitted`
146
- /// and `DkgResultApproved` events.
147
- /// - The `walletMemberIndex` must be in range [1, walletMembersIDs.length]
146
+ /// and `DkgResultApproved` events,
147
+ /// - The `walletMemberIndex` must be in range [1, walletMembersIDs.length],
148
148
  /// - The caller must be the member of the source wallet signing group
149
- /// at the position indicated by `walletMemberIndex` parameter
149
+ /// at the position indicated by `walletMemberIndex` parameter,
150
150
  /// - The `walletMainUtxo` components must point to the recent main
151
151
  /// UTXO of the source wallet, as currently known on the Ethereum
152
- /// chain.
153
- /// - Source wallet BTC balance must be greater than zero
154
- /// - At least one Live wallet must exist in the system
152
+ /// chain,
153
+ /// - Source wallet BTC balance must be greater than zero,
154
+ /// - At least one Live wallet must exist in the system,
155
155
  /// - Submitted target wallets count must match the expected count
156
156
  /// `N = min(liveWalletsCount, ceil(walletBtcBalance / walletMaxBtcTransfer))`
157
- /// where `N > 0`
158
- /// - Each target wallet must be not equal to the source wallet
157
+ /// where `N > 0`,
158
+ /// - Each target wallet must be not equal to the source wallet,
159
159
  /// - Each target wallet must follow the expected order i.e. all
160
160
  /// target wallets 20-byte public key hashes represented as numbers
161
- /// must form a strictly increasing sequence without duplicates.
162
- /// - Each target wallet must be in Live state
161
+ /// must form a strictly increasing sequence without duplicates,
162
+ /// - Each target wallet must be in Live state.
163
163
  function submitMovingFundsCommitment(
164
164
  BridgeState.Storage storage self,
165
165
  bytes20 walletPubKeyHash,
@@ -265,10 +265,10 @@ library MovingFunds {
265
265
  /// of live wallets in the system.
266
266
  /// @param walletPubKeyHash 20-byte public key hash of the moving funds wallet
267
267
  /// @dev Requirements:
268
- /// - The wallet must be in the MovingFunds state
268
+ /// - The wallet must be in the MovingFunds state,
269
269
  /// - The target wallets commitment must not be already submitted for
270
- /// the given moving funds wallet
271
- /// - Live wallets count must be zero
270
+ /// the given moving funds wallet,
271
+ /// - Live wallets count must be zero.
272
272
  function resetMovingFundsTimeout(
273
273
  BridgeState.Storage storage self,
274
274
  bytes20 walletPubKeyHash
@@ -310,37 +310,37 @@ library MovingFunds {
310
310
  ///
311
311
  /// It is possible to prove the given moving funds transaction only
312
312
  /// one time.
313
- /// @param movingFundsTx Bitcoin moving funds transaction data
314
- /// @param movingFundsProof Bitcoin moving funds proof data
313
+ /// @param movingFundsTx Bitcoin moving funds transaction data.
314
+ /// @param movingFundsProof Bitcoin moving funds proof data.
315
315
  /// @param mainUtxo Data of the wallet's main UTXO, as currently known on
316
- /// the Ethereum chain
316
+ /// the Ethereum chain.
317
317
  /// @param walletPubKeyHash 20-byte public key hash (computed using Bitcoin
318
318
  /// HASH160 over the compressed ECDSA public key) of the wallet
319
- /// which performed the moving funds transaction
319
+ /// which performed the moving funds transaction.
320
320
  /// @dev Requirements:
321
321
  /// - `movingFundsTx` components must match the expected structure. See
322
322
  /// `BitcoinTx.Info` docs for reference. Their values must exactly
323
323
  /// correspond to appropriate Bitcoin transaction fields to produce
324
- /// a provable transaction hash.
324
+ /// a provable transaction hash,
325
325
  /// - The `movingFundsTx` should represent a Bitcoin transaction with
326
326
  /// exactly 1 input that refers to the wallet's main UTXO. That
327
327
  /// transaction should have 1..n outputs corresponding to the
328
328
  /// pre-committed target wallets. Outputs must be ordered in the
329
329
  /// same way as their corresponding target wallets are ordered
330
- /// within the target wallets commitment.
330
+ /// within the target wallets commitment,
331
331
  /// - `movingFundsProof` components must match the expected structure.
332
332
  /// See `BitcoinTx.Proof` docs for reference. The `bitcoinHeaders`
333
333
  /// field must contain a valid number of block headers, not less
334
- /// than the `txProofDifficultyFactor` contract constant.
334
+ /// than the `txProofDifficultyFactor` contract constant,
335
335
  /// - `mainUtxo` components must point to the recent main UTXO
336
336
  /// of the given wallet, as currently known on the Ethereum chain.
337
- /// Additionally, the recent main UTXO on Ethereum must be set.
337
+ /// Additionally, the recent main UTXO on Ethereum must be set,
338
338
  /// - `walletPubKeyHash` must be connected with the main UTXO used
339
- /// as transaction single input.
339
+ /// as transaction single input,
340
340
  /// - The wallet that `walletPubKeyHash` points to must be in the
341
- /// MovingFunds state.
341
+ /// MovingFunds state,
342
342
  /// - The target wallets commitment must be submitted by the wallet
343
- /// that `walletPubKeyHash` points to.
343
+ /// that `walletPubKeyHash` points to,
344
344
  /// - The total Bitcoin transaction fee must be lesser or equal
345
345
  /// to `movingFundsTxMaxTotalFee` governable parameter.
346
346
  function submitMovingFundsProof(
@@ -399,8 +399,8 @@ library MovingFunds {
399
399
  /// @return outputsTotalValue Sum of all outputs values.
400
400
  /// @dev Requirements:
401
401
  /// - The `movingFundsTxOutputVector` must be parseable, i.e. must
402
- /// be validated by the caller as stated in their parameter doc.
403
- /// - Each output must refer to a 20-byte public key hash.
402
+ /// be validated by the caller as stated in their parameter doc,
403
+ /// - Each output must refer to a 20-byte public key hash,
404
404
  /// - The total outputs value must be evenly divided over all outputs.
405
405
  function processMovingFundsTxOutputs(
406
406
  BridgeState.Storage storage self,
@@ -523,17 +523,17 @@ library MovingFunds {
523
523
 
524
524
  /// @notice Notifies about a timed out moving funds process. Terminates
525
525
  /// the wallet and slashes signing group members as a result.
526
- /// @param walletPubKeyHash 20-byte public key hash of the wallet
527
- /// @param walletMembersIDs Identifiers of the wallet signing group members
526
+ /// @param walletPubKeyHash 20-byte public key hash of the wallet.
527
+ /// @param walletMembersIDs Identifiers of the wallet signing group members.
528
528
  /// @dev Requirements:
529
- /// - The wallet must be in the MovingFunds state
530
- /// - The moving funds timeout must be actually exceeded
529
+ /// - The wallet must be in the MovingFunds state,
530
+ /// - The moving funds timeout must be actually exceeded,
531
531
  /// - The expression `keccak256(abi.encode(walletMembersIDs))` must
532
532
  /// be exactly the same as the hash stored under `membersIdsHash`
533
533
  /// for the given `walletID`. Those IDs are not directly stored
534
534
  /// in the contract for gas efficiency purposes but they can be
535
535
  /// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`
536
- /// events of the `WalletRegistry` contract
536
+ /// events of the `WalletRegistry` contract.
537
537
  function notifyMovingFundsTimeout(
538
538
  BridgeState.Storage storage self,
539
539
  bytes20 walletPubKeyHash,
@@ -572,16 +572,16 @@ library MovingFunds {
572
572
  /// @notice Notifies about a moving funds wallet whose BTC balance is
573
573
  /// below the moving funds dust threshold. Ends the moving funds
574
574
  /// process and begins wallet closing immediately.
575
- /// @param walletPubKeyHash 20-byte public key hash of the wallet
575
+ /// @param walletPubKeyHash 20-byte public key hash of the wallet.
576
576
  /// @param mainUtxo Data of the wallet's main UTXO, as currently known
577
577
  /// on the Ethereum chain.
578
578
  /// @dev Requirements:
579
- /// - The wallet must be in the MovingFunds state
579
+ /// - The wallet must be in the MovingFunds state,
580
580
  /// - The `mainUtxo` components must point to the recent main UTXO
581
581
  /// of the given wallet, as currently known on the Ethereum chain.
582
582
  /// If the wallet has no main UTXO, this parameter can be empty as it
583
- /// is ignored.
584
- /// - The wallet BTC balance must be below the moving funds threshold
583
+ /// is ignored,
584
+ /// - The wallet BTC balance must be below the moving funds threshold.
585
585
  function notifyMovingFundsBelowDust(
586
586
  BridgeState.Storage storage self,
587
587
  bytes20 walletPubKeyHash,
@@ -626,29 +626,29 @@ library MovingFunds {
626
626
  ///
627
627
  /// It is possible to prove the given sweep transaction only
628
628
  /// one time.
629
- /// @param sweepTx Bitcoin sweep funds transaction data
630
- /// @param sweepProof Bitcoin sweep funds proof data
629
+ /// @param sweepTx Bitcoin sweep funds transaction data.
630
+ /// @param sweepProof Bitcoin sweep funds proof data.
631
631
  /// @param mainUtxo Data of the sweeping wallet's main UTXO, as currently
632
- /// known on the Ethereum chain
632
+ /// known on the Ethereum chain.
633
633
  /// @dev Requirements:
634
634
  /// - `sweepTx` components must match the expected structure. See
635
635
  /// `BitcoinTx.Info` docs for reference. Their values must exactly
636
636
  /// correspond to appropriate Bitcoin transaction fields to produce
637
- /// a provable transaction hash.
637
+ /// a provable transaction hash,
638
638
  /// - The `sweepTx` should represent a Bitcoin transaction with
639
639
  /// the first input pointing to a wallet's sweep Pending request and,
640
640
  /// optionally, the second input pointing to the wallet's main UTXO,
641
641
  /// if the sweeping wallet has a main UTXO set. There should be only
642
642
  /// one output locking funds on the sweeping wallet 20-byte public
643
- /// key hash.
643
+ /// key hash,
644
644
  /// - `sweepProof` components must match the expected structure.
645
645
  /// See `BitcoinTx.Proof` docs for reference. The `bitcoinHeaders`
646
646
  /// field must contain a valid number of block headers, not less
647
- /// than the `txProofDifficultyFactor` contract constant.
647
+ /// than the `txProofDifficultyFactor` contract constant,
648
648
  /// - `mainUtxo` components must point to the recent main UTXO
649
649
  /// of the sweeping wallet, as currently known on the Ethereum chain.
650
- /// If there is no main UTXO, this parameter is ignored.
651
- /// - The sweeping wallet must be in the Live or MovingFunds state.
650
+ /// If there is no main UTXO, this parameter is ignored,
651
+ /// - The sweeping wallet must be in the Live or MovingFunds state,
652
652
  /// - The total Bitcoin transaction fee must be lesser or equal
653
653
  /// to `movedFundsSweepTxMaxTotalFee` governable parameter.
654
654
  function submitMovedFundsSweepProof(
@@ -705,13 +705,13 @@ library MovingFunds {
705
705
  /// vector.
706
706
  /// This function assumes vector's structure is valid so it must be
707
707
  /// validated using e.g. `BTCUtils.validateVout` function before
708
- /// it is passed here
708
+ /// it is passed here.
709
709
  /// @return walletPubKeyHash 20-byte wallet public key hash.
710
710
  /// @return value 8-byte moved funds sweep transaction output value.
711
711
  /// @dev Requirements:
712
- /// - Output vector must contain only one output
712
+ /// - Output vector must contain only one output,
713
713
  /// - The single output must be of P2PKH or P2WPKH type and lock the
714
- /// funds on a 20-byte public key hash
714
+ /// funds on a 20-byte public key hash.
715
715
  function processMovedFundsSweepTxOutput(
716
716
  BridgeState.Storage storage self,
717
717
  bytes memory sweepTxOutputVector
@@ -745,14 +745,14 @@ library MovingFunds {
745
745
  /// Bitcoin transaction.
746
746
  /// @param mainUtxo Data of the wallet's main UTXO, as currently known on
747
747
  /// the Ethereum chain. If no main UTXO exists for the given wallet,
748
- /// this parameter is ignored
748
+ /// this parameter is ignored.
749
749
  /// @return wallet Data of the sweeping wallet.
750
750
  /// @return resolvedMainUtxo The actual main UTXO of the sweeping wallet
751
751
  /// resolved by cross-checking the `mainUtxo` parameter with
752
752
  /// the chain state. If the validation went well, this is the
753
753
  /// plain-text main UTXO corresponding to the `wallet.mainUtxoHash`.
754
754
  /// @dev Requirements:
755
- /// - Sweeping wallet must be either in Live or MovingFunds state.
755
+ /// - Sweeping wallet must be either in Live or MovingFunds state,
756
756
  /// - If the main UTXO of the sweeping wallet exists in the storage,
757
757
  /// the passed `mainUTXO` parameter must be equal to the stored one.
758
758
  function resolveMovedFundsSweepingWallet(
@@ -807,19 +807,19 @@ library MovingFunds {
807
807
  /// @param sweepTxInputVector Bitcoin moved funds sweep transaction input vector.
808
808
  /// This function assumes vector's structure is valid so it must be
809
809
  /// validated using e.g. `BTCUtils.validateVin` function before
810
- /// it is passed here
810
+ /// it is passed here.
811
811
  /// @param mainUtxo Data of the sweeping wallet's main UTXO. If no main UTXO
812
812
  /// exists for the given the wallet, this parameter's fields should
813
- /// be zeroed to bypass the main UTXO validation
814
- /// @param walletPubKeyHash 20-byte public key hash of the sweeping wallet
813
+ /// be zeroed to bypass the main UTXO validation.
814
+ /// @param walletPubKeyHash 20-byte public key hash of the sweeping wallet.
815
815
  /// @return inputsTotalValue Total inputs value sum.
816
816
  /// @dev Requirements:
817
817
  /// - The input vector must consist of one mandatory and one optional
818
- /// input.
819
- /// - The mandatory input must be the first input in the vector
818
+ /// input,
819
+ /// - The mandatory input must be the first input in the vector,
820
820
  /// - The mandatory input must point to a Pending moved funds sweep
821
- /// request that is targeted to the sweeping wallet
822
- /// - The optional output must be the second input in the vector
821
+ /// request that is targeted to the sweeping wallet,
822
+ /// - The optional output must be the second input in the vector,
823
823
  /// - The optional input is required if the sweeping wallet has a
824
824
  /// main UTXO (i.e. the `mainUtxo` is not zeroed). In that case,
825
825
  /// that input must point the the sweeping wallet main UTXO.
@@ -956,8 +956,8 @@ library MovingFunds {
956
956
  }
957
957
 
958
958
  /// @notice Parses a Bitcoin transaction input starting at the given index.
959
- /// @param inputVector Bitcoin transaction input vector
960
- /// @param inputStartingIndex Index the given input starts at
959
+ /// @param inputVector Bitcoin transaction input vector.
960
+ /// @param inputStartingIndex Index the given input starts at.
961
961
  /// @return outpointTxHash 32-byte hash of the Bitcoin transaction which is
962
962
  /// pointed in the given input's outpoint.
963
963
  /// @return outpointIndex 4-byte index of the Bitcoin transaction output
@@ -994,21 +994,21 @@ library MovingFunds {
994
994
  /// the wallet and slashes signing group members as a result.
995
995
  /// Marks the given sweep request as TimedOut.
996
996
  /// @param movingFundsTxHash 32-byte hash of the moving funds transaction
997
- /// that caused the sweep request to be created
997
+ /// that caused the sweep request to be created.
998
998
  /// @param movingFundsTxOutputIndex Index of the moving funds transaction
999
999
  /// output that is subject of the sweep request.
1000
- /// @param walletMembersIDs Identifiers of the wallet signing group members
1000
+ /// @param walletMembersIDs Identifiers of the wallet signing group members.
1001
1001
  /// @dev Requirements:
1002
- /// - The moved funds sweep request must be in the Pending state
1003
- /// - The moved funds sweep timeout must be actually exceeded
1002
+ /// - The moved funds sweep request must be in the Pending state,
1003
+ /// - The moved funds sweep timeout must be actually exceeded,
1004
1004
  /// - The wallet must be either in the Live or MovingFunds or
1005
- /// Terminated state
1005
+ /// Terminated state,,
1006
1006
  /// - The expression `keccak256(abi.encode(walletMembersIDs))` must
1007
1007
  /// be exactly the same as the hash stored under `membersIdsHash`
1008
1008
  /// for the given `walletID`. Those IDs are not directly stored
1009
1009
  /// in the contract for gas efficiency purposes but they can be
1010
1010
  /// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`
1011
- /// events of the `WalletRegistry` contract
1011
+ /// events of the `WalletRegistry` contract.
1012
1012
  function notifyMovedFundsSweepTimeout(
1013
1013
  BridgeState.Storage storage self,
1014
1014
  bytes32 movingFundsTxHash,
@@ -39,7 +39,7 @@ library OutboundTx {
39
39
  /// @param walletOutboundTxInputVector Bitcoin outbound transaction's input
40
40
  /// vector. This function assumes vector's structure is valid so it
41
41
  /// must be validated using e.g. `BTCUtils.validateVin` function
42
- /// before it is passed here
42
+ /// before it is passed here.
43
43
  /// @param mainUtxo Data of the wallet's main UTXO, as currently known on
44
44
  /// the Ethereum chain.
45
45
  /// @param walletPubKeyHash 20-byte public key hash (computed using Bitcoin
@@ -101,7 +101,7 @@ library OutboundTx {
101
101
  /// @param walletOutboundTxInputVector Bitcoin outbound transaction input
102
102
  /// vector. This function assumes vector's structure is valid so it
103
103
  /// must be validated using e.g. `BTCUtils.validateVin` function
104
- /// before it is passed here
104
+ /// before it is passed here.
105
105
  /// @return outpointTxHash 32-byte hash of the Bitcoin transaction which is
106
106
  /// pointed in the input's outpoint.
107
107
  /// @return outpointIndex 4-byte index of the Bitcoin transaction output
@@ -234,12 +234,12 @@ library Redemption {
234
234
  /// @notice Requests redemption of the given amount from the specified
235
235
  /// wallet to the redeemer Bitcoin output script.
236
236
  /// @param walletPubKeyHash The 20-byte wallet public key hash (computed
237
- /// using Bitcoin HASH160 over the compressed ECDSA public key)
237
+ /// using Bitcoin HASH160 over the compressed ECDSA public key).
238
238
  /// @param mainUtxo Data of the wallet's main UTXO, as currently known on
239
- /// the Ethereum chain
239
+ /// the Ethereum chain.
240
240
  /// @param redeemerOutputScript The redeemer's length-prefixed output
241
241
  /// script (P2PKH, P2WPKH, P2SH or P2WSH) that will be used to lock
242
- /// redeemed BTC
242
+ /// redeemed BTC.
243
243
  /// @param amount Requested amount in satoshi. This is also the TBTC amount
244
244
  /// that is taken from redeemer's balance in the Bank upon request.
245
245
  /// Once the request is handled, the actual amount of BTC locked
@@ -249,15 +249,15 @@ library Redemption {
249
249
  /// `amount - (amount / redemptionTreasuryFeeDivisor) - redemptionTxMaxFee`.
250
250
  /// Fees values are taken at the moment of request creation.
251
251
  /// @dev Requirements:
252
- /// - Wallet behind `walletPubKeyHash` must be live
252
+ /// - Wallet behind `walletPubKeyHash` must be live,
253
253
  /// - `mainUtxo` components must point to the recent main UTXO
254
- /// of the given wallet, as currently known on the Ethereum chain.
255
- /// - `redeemerOutputScript` must be a proper Bitcoin script
256
- /// - `redeemerOutputScript` cannot have wallet PKH as payload
257
- /// - `amount` must be above or equal the `redemptionDustThreshold`
254
+ /// of the given wallet, as currently known on the Ethereum chain,
255
+ /// - `redeemerOutputScript` must be a proper Bitcoin script,
256
+ /// - `redeemerOutputScript` cannot have wallet PKH as payload,
257
+ /// - `amount` must be above or equal the `redemptionDustThreshold`,
258
258
  /// - Given `walletPubKeyHash` and `redeemerOutputScript` pair can be
259
- /// used for only one pending request at the same time
260
- /// - Wallet must have enough Bitcoin balance to proceed the request
259
+ /// used for only one pending request at the same time,
260
+ /// - Wallet must have enough Bitcoin balance to proceed the request,
261
261
  /// - Redeemer must make an allowance in the Bank that the Bridge
262
262
  /// contract can spend the given `amount`.
263
263
  function requestRedemption(
@@ -292,14 +292,6 @@ library Redemption {
292
292
  "Invalid main UTXO data"
293
293
  );
294
294
 
295
- // TODO: Confirm if `walletPubKeyHash` should be validated by checking
296
- // if it is the oldest one who can handle the request. This will
297
- // be suggested by the dApp but may not be respected by users who
298
- // interact directly with the contract. Do we need to enforce it
299
- // here? One option is not to enforce it, to save on gas, but if
300
- // we see this rule is not respected, upgrade Bridge contract to
301
- // require it.
302
-
303
295
  // Validate if redeemer output script is a correct standard type
304
296
  // (P2PKH, P2WPKH, P2SH or P2WSH). This is done by building a stub
305
297
  // output with 0 as value and using `BTCUtils.extractHash` on it. Such
@@ -395,18 +387,18 @@ library Redemption {
395
387
  /// transferring the treasury fee sum to the treasury address.
396
388
  ///
397
389
  /// It is possible to prove the given redemption only one time.
398
- /// @param redemptionTx Bitcoin redemption transaction data
399
- /// @param redemptionProof Bitcoin redemption proof data
390
+ /// @param redemptionTx Bitcoin redemption transaction data.
391
+ /// @param redemptionProof Bitcoin redemption proof data.
400
392
  /// @param mainUtxo Data of the wallet's main UTXO, as currently known on
401
- /// the Ethereum chain
393
+ /// the Ethereum chain.
402
394
  /// @param walletPubKeyHash 20-byte public key hash (computed using Bitcoin
403
395
  /// HASH160 over the compressed ECDSA public key) of the wallet which
404
- /// performed the redemption transaction
396
+ /// performed the redemption transaction.
405
397
  /// @dev Requirements:
406
398
  /// - `redemptionTx` components must match the expected structure. See
407
399
  /// `BitcoinTx.Info` docs for reference. Their values must exactly
408
400
  /// correspond to appropriate Bitcoin transaction fields to produce
409
- /// a provable transaction hash.
401
+ /// a provable transaction hash,
410
402
  /// - The `redemptionTx` should represent a Bitcoin transaction with
411
403
  /// exactly 1 input that refers to the wallet's main UTXO. That
412
404
  /// transaction should have 1..n outputs handling existing pending
@@ -414,14 +406,14 @@ library Redemption {
414
406
  /// There can be also 1 optional output representing the
415
407
  /// change and pointing back to the 20-byte wallet public key hash.
416
408
  /// The change should be always present if the redeemed value sum
417
- /// is lower than the total wallet's BTC balance.
409
+ /// is lower than the total wallet's BTC balance,
418
410
  /// - `redemptionProof` components must match the expected structure.
419
411
  /// See `BitcoinTx.Proof` docs for reference. The `bitcoinHeaders`
420
412
  /// field must contain a valid number of block headers, not less
421
- /// than the `txProofDifficultyFactor` contract constant.
413
+ /// than the `txProofDifficultyFactor` contract constant,
422
414
  /// - `mainUtxo` components must point to the recent main UTXO
423
415
  /// of the given wallet, as currently known on the Ethereum chain.
424
- /// Additionally, the recent main UTXO on Ethereum must be set.
416
+ /// Additionally, the recent main UTXO on Ethereum must be set,
425
417
  /// - `walletPubKeyHash` must be connected with the main UTXO used
426
418
  /// as transaction single input.
427
419
  /// Other remarks:
@@ -508,7 +500,7 @@ library Redemption {
508
500
  /// @param redemptionTxOutputVector Bitcoin redemption transaction output
509
501
  /// vector. This function assumes vector's structure is valid so it
510
502
  /// must be validated using e.g. `BTCUtils.validateVout` function
511
- /// before it is passed here
503
+ /// before it is passed here.
512
504
  /// @param walletPubKeyHash 20-byte public key hash (computed using Bitcoin
513
505
  // HASH160 over the compressed ECDSA public key) of the wallet which
514
506
  /// performed the redemption transaction.
@@ -593,7 +585,7 @@ library Redemption {
593
585
  /// @param redemptionTxOutputVector Bitcoin redemption transaction output
594
586
  /// vector. This function assumes vector's structure is valid so it
595
587
  /// must be validated using e.g. `BTCUtils.validateVout` function
596
- /// before it is passed here
588
+ /// before it is passed here.
597
589
  /// @param walletPubKeyHash 20-byte public key hash (computed using Bitcoin
598
590
  // HASH160 over the compressed ECDSA public key) of the wallet which
599
591
  /// performed the redemption transaction.
@@ -616,6 +608,7 @@ library Redemption {
616
608
  // TODO: Check if we can optimize gas costs by adding
617
609
  // `extractValueAt` and `extractHashAt` in `bitcoin-spv-sol`
618
610
  // in order to avoid allocating bytes in memory.
611
+ // https://github.com/keep-network/tbtc-v2/issues/257
619
612
  uint256 outputLength = redemptionTxOutputVector
620
613
  .determineOutputLengthAt(processInfo.outputStartingIndex);
621
614
  bytes memory output = redemptionTxOutputVector.slice(
@@ -685,8 +678,8 @@ library Redemption {
685
678
  /// @param walletPubKeyHash 20-byte public key hash (computed using Bitcoin
686
679
  // HASH160 over the compressed ECDSA public key) of the wallet which
687
680
  /// performed the redemption transaction.
688
- /// @param outputScript Non-change output script to be processed
689
- /// @param outputValue Value of the output being processed
681
+ /// @param outputScript Non-change output script to be processed.
682
+ /// @param outputValue Value of the output being processed.
690
683
  /// @return burnableValue The value burnable as a result of processing this
691
684
  /// single redemption output. This value needs to be summed up with
692
685
  /// burnable values of all other outputs to evaluate total burnable
@@ -786,23 +779,23 @@ library Redemption {
786
779
  /// marked as `MovingFunds` (depending on the presence or absence
787
780
  /// of the wallet's main UTXO) and the wallet will no longer be
788
781
  /// marked as the active wallet (if it was marked as such).
789
- /// @param walletPubKeyHash 20-byte public key hash of the wallet
790
- /// @param walletMembersIDs Identifiers of the wallet signing group members
782
+ /// @param walletPubKeyHash 20-byte public key hash of the wallet.
783
+ /// @param walletMembersIDs Identifiers of the wallet signing group members.
791
784
  /// @param redeemerOutputScript The redeemer's length-prefixed output
792
- /// script (P2PKH, P2WPKH, P2SH or P2WSH)
785
+ /// script (P2PKH, P2WPKH, P2SH or P2WSH).
793
786
  /// @dev Requirements:
794
- /// - The wallet must be in the Live or MovingFunds or Terminated state
787
+ /// - The wallet must be in the Live or MovingFunds or Terminated state,
795
788
  /// - The redemption request identified by `walletPubKeyHash` and
796
- /// `redeemerOutputScript` must exist
789
+ /// `redeemerOutputScript` must exist,
797
790
  /// - The expression `keccak256(abi.encode(walletMembersIDs))` must
798
791
  /// be exactly the same as the hash stored under `membersIdsHash`
799
792
  /// for the given `walletID`. Those IDs are not directly stored
800
793
  /// in the contract for gas efficiency purposes but they can be
801
794
  /// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`
802
- /// events of the `WalletRegistry` contract
795
+ /// events of the `WalletRegistry` contract,
803
796
  /// - The amount of time defined by `redemptionTimeout` must have
804
797
  /// passed since the redemption was requested (the request must be
805
- /// timed-out)
798
+ /// timed-out).
806
799
  function notifyRedemptionTimeout(
807
800
  BridgeState.Storage storage self,
808
801
  bytes20 walletPubKeyHash,