@keep-network/tbtc-v2 0.1.1-dev.72 → 0.1.1-dev.73
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.
- package/artifacts/Bank.json +11 -11
- package/artifacts/DefaultProxyAdmin.json +2 -2
- package/artifacts/Deposit.json +10 -10
- package/artifacts/DepositSweep.json +11 -11
- package/artifacts/EcdsaDkgValidator.json +2 -2
- package/artifacts/EcdsaInactivity.json +1 -1
- package/artifacts/Fraud.json +21 -21
- package/artifacts/KeepRegistry.json +1 -1
- package/artifacts/KeepStake.json +2 -2
- package/artifacts/KeepToken.json +2 -2
- package/artifacts/KeepTokenStaking.json +1 -1
- package/artifacts/MovingFunds.json +31 -31
- package/artifacts/NuCypherStakingEscrow.json +1 -1
- package/artifacts/NuCypherToken.json +2 -2
- package/artifacts/RandomBeaconStub.json +1 -1
- package/artifacts/Redemption.json +22 -22
- package/artifacts/ReimbursementPool.json +2 -2
- package/artifacts/Relay.json +7 -7
- package/artifacts/SortitionPool.json +3 -3
- package/artifacts/T.json +2 -2
- package/artifacts/TBTC.json +3 -3
- package/artifacts/TBTCToken.json +3 -3
- package/artifacts/TokenStaking.json +1 -1
- package/artifacts/TokenholderGovernor.json +9 -9
- package/artifacts/TokenholderTimelock.json +8 -8
- package/artifacts/VendingMachine.json +9 -9
- package/artifacts/VendingMachineKeep.json +1 -1
- package/artifacts/VendingMachineNuCypher.json +1 -1
- package/artifacts/WalletRegistry.json +6 -6
- package/artifacts/WalletRegistry_Implementation.json +1 -1
- package/artifacts/WalletRegistry_Proxy.json +6 -6
- package/artifacts/Wallets.json +14 -14
- package/artifacts/solcInputs/{55df7785455cbf6ded1b912686e91d3f.json → 6b8b6752e7756c1730fe99037bcdde62.json} +15 -15
- package/build/contracts/GovernanceUtils.sol/GovernanceUtils.dbg.json +1 -1
- package/build/contracts/GovernanceUtils.sol/GovernanceUtils.json +2 -2
- package/build/contracts/bank/Bank.sol/Bank.dbg.json +1 -1
- package/build/contracts/bank/Bank.sol/Bank.json +2 -2
- package/build/contracts/bridge/BitcoinTx.sol/BitcoinTx.dbg.json +1 -1
- package/build/contracts/bridge/BitcoinTx.sol/BitcoinTx.json +2 -2
- package/build/contracts/bridge/Bridge.sol/Bridge.dbg.json +1 -1
- package/build/contracts/bridge/Bridge.sol/Bridge.json +2 -2
- package/build/contracts/bridge/BridgeState.sol/BridgeState.dbg.json +1 -1
- package/build/contracts/bridge/BridgeState.sol/BridgeState.json +2 -2
- package/build/contracts/bridge/Deposit.sol/Deposit.dbg.json +1 -1
- package/build/contracts/bridge/Deposit.sol/Deposit.json +2 -2
- package/build/contracts/bridge/DepositSweep.sol/DepositSweep.dbg.json +1 -1
- package/build/contracts/bridge/DepositSweep.sol/DepositSweep.json +2 -2
- package/build/contracts/bridge/EcdsaLib.sol/EcdsaLib.dbg.json +1 -1
- package/build/contracts/bridge/Fraud.sol/Fraud.dbg.json +1 -1
- package/build/contracts/bridge/Fraud.sol/Fraud.json +2 -2
- package/build/contracts/bridge/Heartbeat.sol/Heartbeat.dbg.json +1 -1
- package/build/contracts/bridge/Heartbeat.sol/Heartbeat.json +2 -2
- package/build/contracts/bridge/IRelay.sol/IRelay.dbg.json +1 -1
- package/build/contracts/bridge/MovingFunds.sol/MovingFunds.dbg.json +1 -1
- package/build/contracts/bridge/MovingFunds.sol/MovingFunds.json +2 -2
- package/build/contracts/bridge/Redemption.sol/OutboundTx.dbg.json +1 -1
- package/build/contracts/bridge/Redemption.sol/OutboundTx.json +2 -2
- package/build/contracts/bridge/Redemption.sol/Redemption.dbg.json +1 -1
- package/build/contracts/bridge/Redemption.sol/Redemption.json +2 -2
- package/build/contracts/bridge/VendingMachine.sol/VendingMachine.dbg.json +1 -1
- package/build/contracts/bridge/VendingMachine.sol/VendingMachine.json +2 -2
- package/build/contracts/bridge/Wallets.sol/Wallets.dbg.json +1 -1
- package/build/contracts/bridge/Wallets.sol/Wallets.json +2 -2
- package/build/contracts/token/TBTC.sol/TBTC.dbg.json +1 -1
- package/build/contracts/vault/DonationVault.sol/DonationVault.dbg.json +1 -1
- package/build/contracts/vault/DonationVault.sol/DonationVault.json +2 -2
- package/build/contracts/vault/IVault.sol/IVault.dbg.json +1 -1
- package/build/contracts/vault/TBTCVault.sol/TBTCVault.dbg.json +1 -1
- package/build/contracts/vault/TBTCVault.sol/TBTCVault.json +2 -2
- package/contracts/GovernanceUtils.sol +3 -3
- package/contracts/bank/Bank.sol +2 -2
- package/contracts/bridge/BitcoinTx.sol +7 -7
- package/contracts/bridge/Bridge.sol +192 -195
- package/contracts/bridge/BridgeState.sol +43 -43
- package/contracts/bridge/Deposit.sol +5 -5
- package/contracts/bridge/DepositSweep.sol +12 -12
- package/contracts/bridge/Fraud.sol +25 -25
- package/contracts/bridge/Heartbeat.sol +1 -1
- package/contracts/bridge/MovingFunds.sol +72 -72
- package/contracts/bridge/Redemption.sol +31 -31
- package/contracts/bridge/Wallets.sol +29 -29
- package/contracts/vault/DonationVault.sol +9 -9
- package/contracts/vault/IVault.sol +4 -4
- package/contracts/vault/TBTCVault.sol +14 -14
- package/package.json +1 -1
|
@@ -58,9 +58,6 @@ import "../bank/Bank.sol";
|
|
|
58
58
|
/// @dev Bridge is an upgradeable component of the Bank. The order of
|
|
59
59
|
/// functionalities in this contract is: deposit, sweep, redemption,
|
|
60
60
|
/// moving funds, wallet lifecycle, frauds, parameters.
|
|
61
|
-
///
|
|
62
|
-
/// TODO: Align the convention around `param` and `dev` endings. They should
|
|
63
|
-
/// not have a punctuation mark.
|
|
64
61
|
contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
65
62
|
using BridgeState for BridgeState.Storage;
|
|
66
63
|
using Deposit for BridgeState.Storage;
|
|
@@ -225,14 +222,14 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
225
222
|
);
|
|
226
223
|
|
|
227
224
|
/// @dev Initializes upgradable contract on deployment.
|
|
228
|
-
/// @param _bank Address of the Bank the Bridge belongs to
|
|
225
|
+
/// @param _bank Address of the Bank the Bridge belongs to.
|
|
229
226
|
/// @param _relay Address of the Bitcoin relay providing the current Bitcoin
|
|
230
|
-
/// network difficulty
|
|
227
|
+
/// network difficulty.
|
|
231
228
|
/// @param _treasury Address where the deposit and redemption treasury fees
|
|
232
|
-
/// will be sent to
|
|
233
|
-
/// @param _ecdsaWalletRegistry Address of the ECDSA Wallet Registry contract
|
|
229
|
+
/// will be sent to.
|
|
230
|
+
/// @param _ecdsaWalletRegistry Address of the ECDSA Wallet Registry contract.
|
|
234
231
|
/// @param _txProofDifficultyFactor The number of confirmations on the Bitcoin
|
|
235
|
-
/// chain required to successfully evaluate an SPV proof
|
|
232
|
+
/// chain required to successfully evaluate an SPV proof.
|
|
236
233
|
function initialize(
|
|
237
234
|
address _bank,
|
|
238
235
|
address _relay,
|
|
@@ -302,13 +299,13 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
302
299
|
/// outputs. The deposit may be routed to one of the trusted vaults.
|
|
303
300
|
/// When a deposit is routed to a vault, vault gets notified when
|
|
304
301
|
/// the deposit gets swept and it may execute the appropriate action.
|
|
305
|
-
/// @param fundingTx Bitcoin funding transaction data, see `BitcoinTx.Info
|
|
306
|
-
/// @param reveal Deposit reveal data, see `RevealInfo struct
|
|
302
|
+
/// @param fundingTx Bitcoin funding transaction data, see `BitcoinTx.Info`.
|
|
303
|
+
/// @param reveal Deposit reveal data, see `RevealInfo struct.
|
|
307
304
|
/// @dev Requirements:
|
|
308
|
-
/// - `reveal.walletPubKeyHash` must identify a `Live` wallet
|
|
309
|
-
/// - `reveal.vault` must be 0x0 or point to a trusted vault
|
|
305
|
+
/// - `reveal.walletPubKeyHash` must identify a `Live` wallet,
|
|
306
|
+
/// - `reveal.vault` must be 0x0 or point to a trusted vault,
|
|
310
307
|
/// - `reveal.fundingOutputIndex` must point to the actual P2(W)SH
|
|
311
|
-
/// output of the BTC deposit transaction
|
|
308
|
+
/// output of the BTC deposit transaction,
|
|
312
309
|
/// - `reveal.depositor` must be the Ethereum address used in the
|
|
313
310
|
/// P2(W)SH BTC deposit transaction,
|
|
314
311
|
/// - `reveal.blindingFactor` must be the blinding factor used in the
|
|
@@ -343,11 +340,11 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
343
340
|
/// during the reveal transaction, minus their fee share.
|
|
344
341
|
///
|
|
345
342
|
/// It is possible to prove the given sweep only one time.
|
|
346
|
-
/// @param sweepTx Bitcoin sweep transaction data
|
|
347
|
-
/// @param sweepProof Bitcoin sweep proof data
|
|
343
|
+
/// @param sweepTx Bitcoin sweep transaction data.
|
|
344
|
+
/// @param sweepProof Bitcoin sweep proof data.
|
|
348
345
|
/// @param mainUtxo Data of the wallet's main UTXO, as currently known on
|
|
349
346
|
/// the Ethereum chain. If no main UTXO exists for the given wallet,
|
|
350
|
-
/// this parameter is ignored
|
|
347
|
+
/// this parameter is ignored.
|
|
351
348
|
/// @param vault Optional address of the vault where all swept deposits
|
|
352
349
|
/// should be routed to. All deposits swept as part of the transaction
|
|
353
350
|
/// must have their `vault` parameters set to the same address.
|
|
@@ -361,7 +358,7 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
361
358
|
/// - `sweepTx` components must match the expected structure. See
|
|
362
359
|
/// `BitcoinTx.Info` docs for reference. Their values must exactly
|
|
363
360
|
/// correspond to appropriate Bitcoin transaction fields to produce
|
|
364
|
-
/// a provable transaction hash
|
|
361
|
+
/// a provable transaction hash,
|
|
365
362
|
/// - The `sweepTx` should represent a Bitcoin transaction with 1..n
|
|
366
363
|
/// inputs. If the wallet has no main UTXO, all n inputs should
|
|
367
364
|
/// correspond to P2(W)SH revealed deposits UTXOs. If the wallet has
|
|
@@ -369,14 +366,14 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
369
366
|
/// main UTXO and remaining n-1 inputs should correspond to P2(W)SH
|
|
370
367
|
/// revealed deposits UTXOs. That transaction must have only
|
|
371
368
|
/// one P2(W)PKH output locking funds on the 20-byte wallet public
|
|
372
|
-
/// key hash
|
|
369
|
+
/// key hash,
|
|
373
370
|
/// - All revealed deposits that are swept by `sweepTx` must have
|
|
374
371
|
/// their `vault` parameters set to the same address as the address
|
|
375
|
-
/// passed in the `vault` function parameter
|
|
372
|
+
/// passed in the `vault` function parameter,
|
|
376
373
|
/// - `sweepProof` components must match the expected structure. See
|
|
377
374
|
/// `BitcoinTx.Proof` docs for reference. The `bitcoinHeaders`
|
|
378
375
|
/// field must contain a valid number of block headers, not less
|
|
379
|
-
/// than the `txProofDifficultyFactor` contract constant
|
|
376
|
+
/// than the `txProofDifficultyFactor` contract constant,
|
|
380
377
|
/// - `mainUtxo` components must point to the recent main UTXO
|
|
381
378
|
/// of the given wallet, as currently known on the Ethereum chain.
|
|
382
379
|
/// If there is no main UTXO, this parameter is ignored.
|
|
@@ -392,12 +389,12 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
392
389
|
/// @notice Requests redemption of the given amount from the specified
|
|
393
390
|
/// wallet to the redeemer Bitcoin output script.
|
|
394
391
|
/// @param walletPubKeyHash The 20-byte wallet public key hash (computed
|
|
395
|
-
/// using Bitcoin HASH160 over the compressed ECDSA public key)
|
|
392
|
+
/// using Bitcoin HASH160 over the compressed ECDSA public key).
|
|
396
393
|
/// @param mainUtxo Data of the wallet's main UTXO, as currently known on
|
|
397
|
-
/// the Ethereum chain
|
|
394
|
+
/// the Ethereum chain.
|
|
398
395
|
/// @param redeemerOutputScript The redeemer's length-prefixed output
|
|
399
396
|
/// script (P2PKH, P2WPKH, P2SH or P2WSH) that will be used to lock
|
|
400
|
-
/// redeemed BTC
|
|
397
|
+
/// redeemed BTC.
|
|
401
398
|
/// @param amount Requested amount in satoshi. This is also the TBTC amount
|
|
402
399
|
/// that is taken from redeemer's balance in the Bank upon request.
|
|
403
400
|
/// Once the request is handled, the actual amount of BTC locked
|
|
@@ -407,15 +404,15 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
407
404
|
/// `amount - (amount / redemptionTreasuryFeeDivisor) - redemptionTxMaxFee`.
|
|
408
405
|
/// Fees values are taken at the moment of request creation.
|
|
409
406
|
/// @dev Requirements:
|
|
410
|
-
/// - Wallet behind `walletPubKeyHash` must be live
|
|
407
|
+
/// - Wallet behind `walletPubKeyHash` must be live,
|
|
411
408
|
/// - `mainUtxo` components must point to the recent main UTXO
|
|
412
|
-
/// of the given wallet, as currently known on the Ethereum chain
|
|
413
|
-
/// - `redeemerOutputScript` must be a proper Bitcoin script
|
|
414
|
-
/// - `redeemerOutputScript` cannot have wallet PKH as payload
|
|
415
|
-
/// - `amount` must be above or equal the `redemptionDustThreshold
|
|
409
|
+
/// of the given wallet, as currently known on the Ethereum chain,
|
|
410
|
+
/// - `redeemerOutputScript` must be a proper Bitcoin script,
|
|
411
|
+
/// - `redeemerOutputScript` cannot have wallet PKH as payload,
|
|
412
|
+
/// - `amount` must be above or equal the `redemptionDustThreshold`,
|
|
416
413
|
/// - Given `walletPubKeyHash` and `redeemerOutputScript` pair can be
|
|
417
|
-
/// used for only one pending request at the same time
|
|
418
|
-
/// - Wallet must have enough Bitcoin balance to proceed the request
|
|
414
|
+
/// used for only one pending request at the same time,
|
|
415
|
+
/// - Wallet must have enough Bitcoin balance to proceed the request,
|
|
419
416
|
/// - Redeemer must make an allowance in the Bank that the Bridge
|
|
420
417
|
/// contract can spend the given `amount`.
|
|
421
418
|
function requestRedemption(
|
|
@@ -441,18 +438,18 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
441
438
|
/// transferring the treasury fee sum to the treasury address.
|
|
442
439
|
///
|
|
443
440
|
/// It is possible to prove the given redemption only one time.
|
|
444
|
-
/// @param redemptionTx Bitcoin redemption transaction data
|
|
445
|
-
/// @param redemptionProof Bitcoin redemption proof data
|
|
441
|
+
/// @param redemptionTx Bitcoin redemption transaction data.
|
|
442
|
+
/// @param redemptionProof Bitcoin redemption proof data.
|
|
446
443
|
/// @param mainUtxo Data of the wallet's main UTXO, as currently known on
|
|
447
|
-
/// the Ethereum chain
|
|
444
|
+
/// the Ethereum chain.
|
|
448
445
|
/// @param walletPubKeyHash 20-byte public key hash (computed using Bitcoin
|
|
449
446
|
/// HASH160 over the compressed ECDSA public key) of the wallet which
|
|
450
|
-
/// performed the redemption transaction
|
|
447
|
+
/// performed the redemption transaction.
|
|
451
448
|
/// @dev Requirements:
|
|
452
449
|
/// - `redemptionTx` components must match the expected structure. See
|
|
453
450
|
/// `BitcoinTx.Info` docs for reference. Their values must exactly
|
|
454
451
|
/// correspond to appropriate Bitcoin transaction fields to produce
|
|
455
|
-
/// a provable transaction hash
|
|
452
|
+
/// a provable transaction hash,
|
|
456
453
|
/// - The `redemptionTx` should represent a Bitcoin transaction with
|
|
457
454
|
/// exactly 1 input that refers to the wallet's main UTXO. That
|
|
458
455
|
/// transaction should have 1..n outputs handling existing pending
|
|
@@ -460,14 +457,14 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
460
457
|
/// There can be also 1 optional output representing the
|
|
461
458
|
/// change and pointing back to the 20-byte wallet public key hash.
|
|
462
459
|
/// The change should be always present if the redeemed value sum
|
|
463
|
-
/// is lower than the total wallet's BTC balance
|
|
460
|
+
/// is lower than the total wallet's BTC balance,
|
|
464
461
|
/// - `redemptionProof` components must match the expected structure.
|
|
465
462
|
/// See `BitcoinTx.Proof` docs for reference. The `bitcoinHeaders`
|
|
466
463
|
/// field must contain a valid number of block headers, not less
|
|
467
|
-
/// than the `txProofDifficultyFactor` contract constant
|
|
464
|
+
/// than the `txProofDifficultyFactor` contract constant,
|
|
468
465
|
/// - `mainUtxo` components must point to the recent main UTXO
|
|
469
466
|
/// of the given wallet, as currently known on the Ethereum chain.
|
|
470
|
-
/// Additionally, the recent main UTXO on Ethereum must be set
|
|
467
|
+
/// Additionally, the recent main UTXO on Ethereum must be set,
|
|
471
468
|
/// - `walletPubKeyHash` must be connected with the main UTXO used
|
|
472
469
|
/// as transaction single input.
|
|
473
470
|
/// Other remarks:
|
|
@@ -495,36 +492,36 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
495
492
|
/// request is identified by the key built as
|
|
496
493
|
/// `keccak256(walletPubKeyHash | redeemerOutputScript)`.
|
|
497
494
|
/// The results of calling this function:
|
|
498
|
-
/// -
|
|
495
|
+
/// - The pending redemptions value for the wallet will be decreased
|
|
499
496
|
/// by the requested amount (minus treasury fee),
|
|
500
|
-
/// -
|
|
497
|
+
/// - The tokens taken from the redeemer on redemption request will
|
|
501
498
|
/// be returned to the redeemer,
|
|
502
|
-
/// -
|
|
499
|
+
/// - The request will be moved from pending redemptions to
|
|
503
500
|
/// timed-out redemptions,
|
|
504
|
-
/// -
|
|
501
|
+
/// - If the state of the wallet is `Live` or `MovingFunds`, the
|
|
505
502
|
/// wallet operators will be slashed and the notifier will be
|
|
506
503
|
/// rewarded,
|
|
507
|
-
/// -
|
|
504
|
+
/// - If the state of wallet is `Live`, the wallet will be closed or
|
|
508
505
|
/// marked as `MovingFunds` (depending on the presence or absence
|
|
509
506
|
/// of the wallet's main UTXO) and the wallet will no longer be
|
|
510
507
|
/// marked as the active wallet (if it was marked as such).
|
|
511
|
-
/// @param walletPubKeyHash 20-byte public key hash of the wallet
|
|
512
|
-
/// @param walletMembersIDs Identifiers of the wallet signing group members
|
|
508
|
+
/// @param walletPubKeyHash 20-byte public key hash of the wallet.
|
|
509
|
+
/// @param walletMembersIDs Identifiers of the wallet signing group members.
|
|
513
510
|
/// @param redeemerOutputScript The redeemer's length-prefixed output
|
|
514
|
-
/// script (P2PKH, P2WPKH, P2SH or P2WSH)
|
|
511
|
+
/// script (P2PKH, P2WPKH, P2SH or P2WSH).
|
|
515
512
|
/// @dev Requirements:
|
|
516
|
-
/// - The wallet must be in the Live or MovingFunds or Terminated state
|
|
513
|
+
/// - The wallet must be in the Live or MovingFunds or Terminated state,
|
|
517
514
|
/// - The redemption request identified by `walletPubKeyHash` and
|
|
518
|
-
/// `redeemerOutputScript` must exist
|
|
515
|
+
/// `redeemerOutputScript` must exist,
|
|
519
516
|
/// - The expression `keccak256(abi.encode(walletMembersIDs))` must
|
|
520
517
|
/// be exactly the same as the hash stored under `membersIdsHash`
|
|
521
518
|
/// for the given `walletID`. Those IDs are not directly stored
|
|
522
519
|
/// in the contract for gas efficiency purposes but they can be
|
|
523
520
|
/// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`
|
|
524
|
-
/// events of the `WalletRegistry` contract
|
|
521
|
+
/// events of the `WalletRegistry` contract,
|
|
525
522
|
/// - The amount of time defined by `redemptionTimeout` must have
|
|
526
523
|
/// passed since the redemption was requested (the request must be
|
|
527
|
-
/// timed-out)
|
|
524
|
+
/// timed-out).
|
|
528
525
|
function notifyRedemptionTimeout(
|
|
529
526
|
bytes20 walletPubKeyHash,
|
|
530
527
|
uint32[] calldata walletMembersIDs,
|
|
@@ -541,42 +538,42 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
541
538
|
/// Once all requirements are met, that function registers the
|
|
542
539
|
/// target wallets commitment and opens the way for moving funds
|
|
543
540
|
/// proof submission.
|
|
544
|
-
/// @param walletPubKeyHash 20-byte public key hash of the source wallet
|
|
541
|
+
/// @param walletPubKeyHash 20-byte public key hash of the source wallet.
|
|
545
542
|
/// @param walletMainUtxo Data of the source wallet's main UTXO, as
|
|
546
|
-
/// currently known on the Ethereum chain
|
|
543
|
+
/// currently known on the Ethereum chain.
|
|
547
544
|
/// @param walletMembersIDs Identifiers of the source wallet signing group
|
|
548
|
-
/// members
|
|
545
|
+
/// members.
|
|
549
546
|
/// @param walletMemberIndex Position of the caller in the source wallet
|
|
550
|
-
/// signing group members list
|
|
547
|
+
/// signing group members list.
|
|
551
548
|
/// @param targetWallets List of 20-byte public key hashes of the target
|
|
552
|
-
/// wallets that the source wallet commits to move the funds to
|
|
549
|
+
/// wallets that the source wallet commits to move the funds to.
|
|
553
550
|
/// @dev Requirements:
|
|
554
|
-
/// - The source wallet must be in the MovingFunds state
|
|
555
|
-
/// - The source wallet must not have pending redemption requests
|
|
556
|
-
/// - The source wallet must not have pending moved funds sweep requests
|
|
557
|
-
/// - The source wallet must not have submitted its commitment already
|
|
551
|
+
/// - The source wallet must be in the MovingFunds state,
|
|
552
|
+
/// - The source wallet must not have pending redemption requests,
|
|
553
|
+
/// - The source wallet must not have pending moved funds sweep requests,
|
|
554
|
+
/// - The source wallet must not have submitted its commitment already,
|
|
558
555
|
/// - The expression `keccak256(abi.encode(walletMembersIDs))` must
|
|
559
556
|
/// be exactly the same as the hash stored under `membersIdsHash`
|
|
560
557
|
/// for the given source wallet in the ECDSA registry. Those IDs are
|
|
561
558
|
/// not directly stored in the contract for gas efficiency purposes
|
|
562
559
|
/// but they can be read from appropriate `DkgResultSubmitted`
|
|
563
|
-
/// and `DkgResultApproved` events
|
|
564
|
-
/// - The `walletMemberIndex` must be in range [1, walletMembersIDs.length]
|
|
560
|
+
/// and `DkgResultApproved` events,
|
|
561
|
+
/// - The `walletMemberIndex` must be in range [1, walletMembersIDs.length],
|
|
565
562
|
/// - The caller must be the member of the source wallet signing group
|
|
566
|
-
/// at the position indicated by `walletMemberIndex` parameter
|
|
563
|
+
/// at the position indicated by `walletMemberIndex` parameter,
|
|
567
564
|
/// - The `walletMainUtxo` components must point to the recent main
|
|
568
565
|
/// UTXO of the source wallet, as currently known on the Ethereum
|
|
569
|
-
/// chain
|
|
570
|
-
/// - Source wallet BTC balance must be greater than zero
|
|
571
|
-
/// - At least one Live wallet must exist in the system
|
|
566
|
+
/// chain,
|
|
567
|
+
/// - Source wallet BTC balance must be greater than zero,
|
|
568
|
+
/// - At least one Live wallet must exist in the system,
|
|
572
569
|
/// - Submitted target wallets count must match the expected count
|
|
573
570
|
/// `N = min(liveWalletsCount, ceil(walletBtcBalance / walletMaxBtcTransfer))`
|
|
574
|
-
/// where `N > 0
|
|
575
|
-
/// - Each target wallet must be not equal to the source wallet
|
|
571
|
+
/// where `N > 0`,
|
|
572
|
+
/// - Each target wallet must be not equal to the source wallet,
|
|
576
573
|
/// - Each target wallet must follow the expected order i.e. all
|
|
577
574
|
/// target wallets 20-byte public key hashes represented as numbers
|
|
578
|
-
/// must form a strictly increasing sequence without duplicates
|
|
579
|
-
/// - Each target wallet must be in Live state
|
|
575
|
+
/// must form a strictly increasing sequence without duplicates,
|
|
576
|
+
/// - Each target wallet must be in Live state.
|
|
580
577
|
function submitMovingFundsCommitment(
|
|
581
578
|
bytes20 walletPubKeyHash,
|
|
582
579
|
BitcoinTx.UTXO calldata walletMainUtxo,
|
|
@@ -596,12 +593,12 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
596
593
|
/// @notice Resets the moving funds timeout for the given wallet if the
|
|
597
594
|
/// target wallet commitment cannot be submitted due to a lack
|
|
598
595
|
/// of live wallets in the system.
|
|
599
|
-
/// @param walletPubKeyHash 20-byte public key hash of the moving funds wallet
|
|
596
|
+
/// @param walletPubKeyHash 20-byte public key hash of the moving funds wallet.
|
|
600
597
|
/// @dev Requirements:
|
|
601
|
-
/// - The wallet must be in the MovingFunds state
|
|
598
|
+
/// - The wallet must be in the MovingFunds state,
|
|
602
599
|
/// - The target wallets commitment must not be already submitted for
|
|
603
|
-
/// the given moving funds wallet
|
|
604
|
-
/// - Live wallets count must be zero
|
|
600
|
+
/// the given moving funds wallet,
|
|
601
|
+
/// - Live wallets count must be zero.
|
|
605
602
|
function resetMovingFundsTimeout(bytes20 walletPubKeyHash) external {
|
|
606
603
|
self.resetMovingFundsTimeout(walletPubKeyHash);
|
|
607
604
|
}
|
|
@@ -618,37 +615,37 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
618
615
|
///
|
|
619
616
|
/// It is possible to prove the given moving funds transaction only
|
|
620
617
|
/// one time.
|
|
621
|
-
/// @param movingFundsTx Bitcoin moving funds transaction data
|
|
622
|
-
/// @param movingFundsProof Bitcoin moving funds proof data
|
|
618
|
+
/// @param movingFundsTx Bitcoin moving funds transaction data.
|
|
619
|
+
/// @param movingFundsProof Bitcoin moving funds proof data.
|
|
623
620
|
/// @param mainUtxo Data of the wallet's main UTXO, as currently known on
|
|
624
|
-
/// the Ethereum chain
|
|
621
|
+
/// the Ethereum chain.
|
|
625
622
|
/// @param walletPubKeyHash 20-byte public key hash (computed using Bitcoin
|
|
626
623
|
/// HASH160 over the compressed ECDSA public key) of the wallet
|
|
627
|
-
/// which performed the moving funds transaction
|
|
624
|
+
/// which performed the moving funds transaction.
|
|
628
625
|
/// @dev Requirements:
|
|
629
626
|
/// - `movingFundsTx` components must match the expected structure. See
|
|
630
627
|
/// `BitcoinTx.Info` docs for reference. Their values must exactly
|
|
631
628
|
/// correspond to appropriate Bitcoin transaction fields to produce
|
|
632
|
-
/// a provable transaction hash
|
|
629
|
+
/// a provable transaction hash,
|
|
633
630
|
/// - The `movingFundsTx` should represent a Bitcoin transaction with
|
|
634
631
|
/// exactly 1 input that refers to the wallet's main UTXO. That
|
|
635
632
|
/// transaction should have 1..n outputs corresponding to the
|
|
636
633
|
/// pre-committed target wallets. Outputs must be ordered in the
|
|
637
634
|
/// same way as their corresponding target wallets are ordered
|
|
638
|
-
/// within the target wallets commitment
|
|
635
|
+
/// within the target wallets commitment,
|
|
639
636
|
/// - `movingFundsProof` components must match the expected structure.
|
|
640
637
|
/// See `BitcoinTx.Proof` docs for reference. The `bitcoinHeaders`
|
|
641
638
|
/// field must contain a valid number of block headers, not less
|
|
642
|
-
/// than the `txProofDifficultyFactor` contract constant
|
|
639
|
+
/// than the `txProofDifficultyFactor` contract constant,
|
|
643
640
|
/// - `mainUtxo` components must point to the recent main UTXO
|
|
644
641
|
/// of the given wallet, as currently known on the Ethereum chain.
|
|
645
|
-
/// Additionally, the recent main UTXO on Ethereum must be set
|
|
642
|
+
/// Additionally, the recent main UTXO on Ethereum must be set,
|
|
646
643
|
/// - `walletPubKeyHash` must be connected with the main UTXO used
|
|
647
|
-
/// as transaction single input
|
|
644
|
+
/// as transaction single input,
|
|
648
645
|
/// - The wallet that `walletPubKeyHash` points to must be in the
|
|
649
|
-
/// MovingFunds state
|
|
646
|
+
/// MovingFunds state,
|
|
650
647
|
/// - The target wallets commitment must be submitted by the wallet
|
|
651
|
-
/// that `walletPubKeyHash` points to
|
|
648
|
+
/// that `walletPubKeyHash` points to,
|
|
652
649
|
/// - The total Bitcoin transaction fee must be lesser or equal
|
|
653
650
|
/// to `movingFundsTxMaxTotalFee` governable parameter.
|
|
654
651
|
function submitMovingFundsProof(
|
|
@@ -667,17 +664,17 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
667
664
|
|
|
668
665
|
/// @notice Notifies about a timed out moving funds process. Terminates
|
|
669
666
|
/// the wallet and slashes signing group members as a result.
|
|
670
|
-
/// @param walletPubKeyHash 20-byte public key hash of the wallet
|
|
671
|
-
/// @param walletMembersIDs Identifiers of the wallet signing group members
|
|
667
|
+
/// @param walletPubKeyHash 20-byte public key hash of the wallet.
|
|
668
|
+
/// @param walletMembersIDs Identifiers of the wallet signing group members.
|
|
672
669
|
/// @dev Requirements:
|
|
673
|
-
/// - The wallet must be in the MovingFunds state
|
|
674
|
-
/// - The moving funds timeout must be actually exceeded
|
|
670
|
+
/// - The wallet must be in the MovingFunds state,
|
|
671
|
+
/// - The moving funds timeout must be actually exceeded,
|
|
675
672
|
/// - The expression `keccak256(abi.encode(walletMembersIDs))` must
|
|
676
673
|
/// be exactly the same as the hash stored under `membersIdsHash`
|
|
677
674
|
/// for the given `walletID`. Those IDs are not directly stored
|
|
678
675
|
/// in the contract for gas efficiency purposes but they can be
|
|
679
676
|
/// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`
|
|
680
|
-
/// events of the `WalletRegistry` contract
|
|
677
|
+
/// events of the `WalletRegistry` contract.
|
|
681
678
|
function notifyMovingFundsTimeout(
|
|
682
679
|
bytes20 walletPubKeyHash,
|
|
683
680
|
uint32[] calldata walletMembersIDs
|
|
@@ -692,12 +689,12 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
692
689
|
/// @param mainUtxo Data of the wallet's main UTXO, as currently known
|
|
693
690
|
/// on the Ethereum chain.
|
|
694
691
|
/// @dev Requirements:
|
|
695
|
-
/// - The wallet must be in the MovingFunds state
|
|
692
|
+
/// - The wallet must be in the MovingFunds state,
|
|
696
693
|
/// - The `mainUtxo` components must point to the recent main UTXO
|
|
697
694
|
/// of the given wallet, as currently known on the Ethereum chain.
|
|
698
695
|
/// If the wallet has no main UTXO, this parameter can be empty as it
|
|
699
|
-
/// is ignored
|
|
700
|
-
/// - The wallet BTC balance must be below the moving funds threshold
|
|
696
|
+
/// is ignored,
|
|
697
|
+
/// - The wallet BTC balance must be below the moving funds threshold.
|
|
701
698
|
function notifyMovingFundsBelowDust(
|
|
702
699
|
bytes20 walletPubKeyHash,
|
|
703
700
|
BitcoinTx.UTXO calldata mainUtxo
|
|
@@ -719,29 +716,29 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
719
716
|
///
|
|
720
717
|
/// It is possible to prove the given sweep transaction only
|
|
721
718
|
/// one time.
|
|
722
|
-
/// @param sweepTx Bitcoin sweep funds transaction data
|
|
723
|
-
/// @param sweepProof Bitcoin sweep funds proof data
|
|
719
|
+
/// @param sweepTx Bitcoin sweep funds transaction data.
|
|
720
|
+
/// @param sweepProof Bitcoin sweep funds proof data.
|
|
724
721
|
/// @param mainUtxo Data of the sweeping wallet's main UTXO, as currently
|
|
725
|
-
/// known on the Ethereum chain
|
|
722
|
+
/// known on the Ethereum chain.
|
|
726
723
|
/// @dev Requirements:
|
|
727
724
|
/// - `sweepTx` components must match the expected structure. See
|
|
728
725
|
/// `BitcoinTx.Info` docs for reference. Their values must exactly
|
|
729
726
|
/// correspond to appropriate Bitcoin transaction fields to produce
|
|
730
|
-
/// a provable transaction hash
|
|
727
|
+
/// a provable transaction hash,
|
|
731
728
|
/// - The `sweepTx` should represent a Bitcoin transaction with
|
|
732
729
|
/// the first input pointing to a moved funds sweep request targeted
|
|
733
730
|
/// to the wallet, and optionally, the second input pointing to the
|
|
734
731
|
/// wallet's main UTXO, if the sweeping wallet has a main UTXO set.
|
|
735
732
|
/// There should be only one output locking funds on the sweeping
|
|
736
|
-
/// wallet 20-byte public key hash
|
|
733
|
+
/// wallet 20-byte public key hash,
|
|
737
734
|
/// - `sweepProof` components must match the expected structure.
|
|
738
735
|
/// See `BitcoinTx.Proof` docs for reference. The `bitcoinHeaders`
|
|
739
736
|
/// field must contain a valid number of block headers, not less
|
|
740
|
-
/// than the `txProofDifficultyFactor` contract constant
|
|
737
|
+
/// than the `txProofDifficultyFactor` contract constant,
|
|
741
738
|
/// - `mainUtxo` components must point to the recent main UTXO
|
|
742
739
|
/// of the sweeping wallet, as currently known on the Ethereum chain.
|
|
743
|
-
/// If there is no main UTXO, this parameter is ignored
|
|
744
|
-
/// - The sweeping wallet must be in the Live or MovingFunds state
|
|
740
|
+
/// If there is no main UTXO, this parameter is ignored,
|
|
741
|
+
/// - The sweeping wallet must be in the Live or MovingFunds state,
|
|
745
742
|
/// - The total Bitcoin transaction fee must be lesser or equal
|
|
746
743
|
/// to `movedFundsSweepTxMaxTotalFee` governable parameter.
|
|
747
744
|
function submitMovedFundsSweepProof(
|
|
@@ -757,21 +754,21 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
757
754
|
/// the wallet and slashes signing group members as a result.
|
|
758
755
|
/// Marks the given sweep request as TimedOut.
|
|
759
756
|
/// @param movingFundsTxHash 32-byte hash of the moving funds transaction
|
|
760
|
-
/// that caused the sweep request to be created
|
|
757
|
+
/// that caused the sweep request to be created.
|
|
761
758
|
/// @param movingFundsTxOutputIndex Index of the moving funds transaction
|
|
762
759
|
/// output that is subject of the sweep request.
|
|
763
|
-
/// @param walletMembersIDs Identifiers of the wallet signing group members
|
|
760
|
+
/// @param walletMembersIDs Identifiers of the wallet signing group members.
|
|
764
761
|
/// @dev Requirements:
|
|
765
|
-
/// - The moved funds sweep request must be in the Pending state
|
|
766
|
-
/// - The moved funds sweep timeout must be actually exceeded
|
|
762
|
+
/// - The moved funds sweep request must be in the Pending state,
|
|
763
|
+
/// - The moved funds sweep timeout must be actually exceeded,
|
|
767
764
|
/// - The wallet must be either in the Live or MovingFunds or
|
|
768
|
-
/// Terminated state
|
|
765
|
+
/// Terminated state,
|
|
769
766
|
/// - The expression `keccak256(abi.encode(walletMembersIDs))` must
|
|
770
767
|
/// be exactly the same as the hash stored under `membersIdsHash`
|
|
771
768
|
/// for the given `walletID`. Those IDs are not directly stored
|
|
772
769
|
/// in the contract for gas efficiency purposes but they can be
|
|
773
770
|
/// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`
|
|
774
|
-
/// events of the `WalletRegistry` contract
|
|
771
|
+
/// events of the `WalletRegistry` contract.
|
|
775
772
|
function notifyMovedFundsSweepTimeout(
|
|
776
773
|
bytes32 movingFundsTxHash,
|
|
777
774
|
uint32 movingFundsTxOutputIndex,
|
|
@@ -796,14 +793,14 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
796
793
|
/// UTXO of the given active wallet, as currently known on the
|
|
797
794
|
/// Ethereum chain. If there is no active wallet at the moment, or
|
|
798
795
|
/// the active wallet has no main UTXO, this parameter can be
|
|
799
|
-
/// empty as it is ignored
|
|
800
|
-
/// - Wallet creation must not be in progress
|
|
796
|
+
/// empty as it is ignored,
|
|
797
|
+
/// - Wallet creation must not be in progress,
|
|
801
798
|
/// - If the active wallet is set, one of the following
|
|
802
799
|
/// conditions must be true:
|
|
803
800
|
/// - The active wallet BTC balance is above the minimum threshold
|
|
804
801
|
/// and the active wallet is old enough, i.e. the creation period
|
|
805
|
-
/// was elapsed since its creation time
|
|
806
|
-
/// - The active wallet BTC balance is above the maximum threshold
|
|
802
|
+
/// was elapsed since its creation time,
|
|
803
|
+
/// - The active wallet BTC balance is above the maximum threshold.
|
|
807
804
|
function requestNewWallet(BitcoinTx.UTXO calldata activeWalletMainUtxo)
|
|
808
805
|
external
|
|
809
806
|
{
|
|
@@ -816,8 +813,8 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
816
813
|
/// @param publicKeyX Wallet's public key's X coordinate.
|
|
817
814
|
/// @param publicKeyY Wallet's public key's Y coordinate.
|
|
818
815
|
/// @dev Requirements:
|
|
819
|
-
/// - The only caller authorized to call this function is `registry
|
|
820
|
-
/// - Given wallet data must not belong to an already registered wallet
|
|
816
|
+
/// - The only caller authorized to call this function is `registry`,
|
|
817
|
+
/// - Given wallet data must not belong to an already registered wallet.
|
|
821
818
|
function __ecdsaWalletCreatedCallback(
|
|
822
819
|
bytes32 ecdsaWalletID,
|
|
823
820
|
bytes32 publicKeyX,
|
|
@@ -828,11 +825,11 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
828
825
|
|
|
829
826
|
/// @notice A callback function that is called by the ECDSA Wallet Registry
|
|
830
827
|
/// once a wallet heartbeat failure is detected.
|
|
831
|
-
/// @param publicKeyX Wallet's public key's X coordinate
|
|
832
|
-
/// @param publicKeyY Wallet's public key's Y coordinate
|
|
828
|
+
/// @param publicKeyX Wallet's public key's X coordinate.
|
|
829
|
+
/// @param publicKeyY Wallet's public key's Y coordinate.
|
|
833
830
|
/// @dev Requirements:
|
|
834
|
-
/// - The only caller authorized to call this function is `registry
|
|
835
|
-
/// - Wallet must be in Live state
|
|
831
|
+
/// - The only caller authorized to call this function is `registry`,
|
|
832
|
+
/// - Wallet must be in Live state.
|
|
836
833
|
function __ecdsaWalletHeartbeatFailedCallback(
|
|
837
834
|
bytes32,
|
|
838
835
|
bytes32 publicKeyX,
|
|
@@ -843,19 +840,19 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
843
840
|
|
|
844
841
|
/// @notice Notifies that the wallet is either old enough or has too few
|
|
845
842
|
/// satoshi left and qualifies to be closed.
|
|
846
|
-
/// @param walletPubKeyHash 20-byte public key hash of the wallet
|
|
843
|
+
/// @param walletPubKeyHash 20-byte public key hash of the wallet.
|
|
847
844
|
/// @param walletMainUtxo Data of the wallet's main UTXO, as currently
|
|
848
845
|
/// known on the Ethereum chain.
|
|
849
846
|
/// @dev Requirements:
|
|
850
|
-
/// - Wallet must not be set as the current active wallet
|
|
847
|
+
/// - Wallet must not be set as the current active wallet,
|
|
851
848
|
/// - Wallet must exceed the wallet maximum age OR the wallet BTC
|
|
852
849
|
/// balance must be lesser than the minimum threshold. If the latter
|
|
853
850
|
/// case is true, the `walletMainUtxo` components must point to the
|
|
854
851
|
/// recent main UTXO of the given wallet, as currently known on the
|
|
855
852
|
/// Ethereum chain. If the wallet has no main UTXO, this parameter
|
|
856
853
|
/// can be empty as it is ignored since the wallet balance is
|
|
857
|
-
/// assumed to be zero
|
|
858
|
-
/// - Wallet must be in Live state
|
|
854
|
+
/// assumed to be zero,
|
|
855
|
+
/// - Wallet must be in Live state.
|
|
859
856
|
function notifyCloseableWallet(
|
|
860
857
|
bytes20 walletPubKeyHash,
|
|
861
858
|
BitcoinTx.UTXO calldata walletMainUtxo
|
|
@@ -866,10 +863,10 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
866
863
|
/// @notice Notifies about the end of the closing period for the given wallet.
|
|
867
864
|
/// Closes the wallet ultimately and notifies the ECDSA registry
|
|
868
865
|
/// about this fact.
|
|
869
|
-
/// @param walletPubKeyHash 20-byte public key hash of the wallet
|
|
866
|
+
/// @param walletPubKeyHash 20-byte public key hash of the wallet.
|
|
870
867
|
/// @dev Requirements:
|
|
871
|
-
/// - The wallet must be in the Closing state
|
|
872
|
-
/// - The wallet closing period must have elapsed
|
|
868
|
+
/// - The wallet must be in the Closing state,
|
|
869
|
+
/// - The wallet closing period must have elapsed.
|
|
873
870
|
function notifyWalletClosingPeriodElapsed(bytes20 walletPubKeyHash)
|
|
874
871
|
external
|
|
875
872
|
{
|
|
@@ -892,7 +889,7 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
892
889
|
/// must deposit ETH that is returned back upon justified fraud
|
|
893
890
|
/// challenge or confiscated otherwise.
|
|
894
891
|
/// @param walletPublicKey The public key of the wallet in the uncompressed
|
|
895
|
-
/// and unprefixed format (64 bytes)
|
|
892
|
+
/// and unprefixed format (64 bytes).
|
|
896
893
|
/// @param preimageSha256 The hash that was generated by applying SHA-256
|
|
897
894
|
/// one time over the preimage used during input signing. The preimage
|
|
898
895
|
/// is a serialized subset of the transaction and its structure
|
|
@@ -900,17 +897,17 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
900
897
|
/// Notice that applying SHA-256 over the `preimageSha256` results
|
|
901
898
|
/// in `sighash`. The path from `preimage` to `sighash` looks like
|
|
902
899
|
/// this:
|
|
903
|
-
/// preimage -> (SHA-256) -> preimageSha256 -> (SHA-256) -> sighash
|
|
904
|
-
/// @param signature Bitcoin signature in the R/S/V format
|
|
900
|
+
/// preimage -> (SHA-256) -> preimageSha256 -> (SHA-256) -> sighash.
|
|
901
|
+
/// @param signature Bitcoin signature in the R/S/V format.
|
|
905
902
|
/// @dev Requirements:
|
|
906
903
|
/// - Wallet behind `walletPublicKey` must be in Live or MovingFunds
|
|
907
|
-
/// or Closing state
|
|
904
|
+
/// or Closing state,
|
|
908
905
|
/// - The challenger must send appropriate amount of ETH used as
|
|
909
|
-
/// fraud challenge deposit
|
|
906
|
+
/// fraud challenge deposit,
|
|
910
907
|
/// - The signature (represented by r, s and v) must be generated by
|
|
911
908
|
/// the wallet behind `walletPubKey` during signing of `sighash`
|
|
912
|
-
/// which was calculated from `preimageSha256
|
|
913
|
-
/// - Wallet can be challenged for the given signature only once
|
|
909
|
+
/// which was calculated from `preimageSha256`,
|
|
910
|
+
/// - Wallet can be challenged for the given signature only once.
|
|
914
911
|
function submitFraudChallenge(
|
|
915
912
|
bytes calldata walletPublicKey,
|
|
916
913
|
bytes memory preimageSha256,
|
|
@@ -932,21 +929,21 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
932
929
|
/// resolved and the amount of ether deposited by the challenger is
|
|
933
930
|
/// sent to the treasury.
|
|
934
931
|
/// @param walletPublicKey The public key of the wallet in the uncompressed
|
|
935
|
-
/// and unprefixed format (64 bytes)
|
|
932
|
+
/// and unprefixed format (64 bytes).
|
|
936
933
|
/// @param preimage The preimage which produces sighash used to generate the
|
|
937
934
|
/// ECDSA signature that is the subject of the fraud claim. It is a
|
|
938
935
|
/// serialized subset of the transaction. The exact subset used as
|
|
939
936
|
/// the preimage depends on the transaction input the signature is
|
|
940
|
-
/// produced for. See BIP-143 for reference
|
|
937
|
+
/// produced for. See BIP-143 for reference.
|
|
941
938
|
/// @param witness Flag indicating whether the preimage was produced for a
|
|
942
|
-
/// witness input. True for witness, false for non-witness input
|
|
939
|
+
/// witness input. True for witness, false for non-witness input.
|
|
943
940
|
/// @dev Requirements:
|
|
944
941
|
/// - `walletPublicKey` and `sighash` calculated as `hash256(preimage)`
|
|
945
|
-
/// must identify an open fraud challenge
|
|
942
|
+
/// must identify an open fraud challenge,
|
|
946
943
|
/// - the preimage must be a valid preimage of a transaction generated
|
|
947
|
-
/// according to the protocol rules and already proved in the Bridge
|
|
944
|
+
/// according to the protocol rules and already proved in the Bridge,
|
|
948
945
|
/// - before a defeat attempt is made the transaction that spends the
|
|
949
|
-
/// given UTXO must be proven in the Bridge
|
|
946
|
+
/// given UTXO must be proven in the Bridge.
|
|
950
947
|
function defeatFraudChallenge(
|
|
951
948
|
bytes calldata walletPublicKey,
|
|
952
949
|
bytes calldata preimage,
|
|
@@ -967,16 +964,16 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
967
964
|
/// challenge is marked as resolved and the amount of ether
|
|
968
965
|
/// deposited by the challenger is sent to the treasury.
|
|
969
966
|
/// @param walletPublicKey The public key of the wallet in the uncompressed
|
|
970
|
-
/// and unprefixed format (64 bytes)
|
|
967
|
+
/// and unprefixed format (64 bytes).
|
|
971
968
|
/// @param heartbeatMessage Off-chain heartbeat message meeting the heartbeat
|
|
972
969
|
/// message format requirements which produces sighash used to
|
|
973
970
|
/// generate the ECDSA signature that is the subject of the fraud
|
|
974
|
-
/// claim
|
|
971
|
+
/// claim.
|
|
975
972
|
/// @dev Requirements:
|
|
976
973
|
/// - `walletPublicKey` and `sighash` calculated as
|
|
977
|
-
/// `hash256(heartbeatMessage)` must identify an open fraud challenge
|
|
974
|
+
/// `hash256(heartbeatMessage)` must identify an open fraud challenge,
|
|
978
975
|
/// - `heartbeatMessage` must follow a strict format of heartbeat
|
|
979
|
-
/// messages
|
|
976
|
+
/// messages.
|
|
980
977
|
function defeatFraudChallengeWithHeartbeat(
|
|
981
978
|
bytes calldata walletPublicKey,
|
|
982
979
|
bytes calldata heartbeatMessage
|
|
@@ -998,8 +995,8 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
998
995
|
/// deposited is returned to the challenger and the challenger is
|
|
999
996
|
/// rewarded.
|
|
1000
997
|
/// @param walletPublicKey The public key of the wallet in the uncompressed
|
|
1001
|
-
/// and unprefixed format (64 bytes)
|
|
1002
|
-
/// @param walletMembersIDs Identifiers of the wallet signing group members
|
|
998
|
+
/// and unprefixed format (64 bytes).
|
|
999
|
+
/// @param walletMembersIDs Identifiers of the wallet signing group members.
|
|
1003
1000
|
/// @param preimageSha256 The hash that was generated by applying SHA-256
|
|
1004
1001
|
/// one time over the preimage used during input signing. The preimage
|
|
1005
1002
|
/// is a serialized subset of the transaction and its structure
|
|
@@ -1007,20 +1004,20 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
1007
1004
|
/// Notice that applying SHA-256 over the `preimageSha256` results
|
|
1008
1005
|
/// in `sighash`. The path from `preimage` to `sighash` looks like
|
|
1009
1006
|
/// this:
|
|
1010
|
-
/// preimage -> (SHA-256) -> preimageSha256 -> (SHA-256) -> sighash
|
|
1007
|
+
/// preimage -> (SHA-256) -> preimageSha256 -> (SHA-256) -> sighash.
|
|
1011
1008
|
/// @dev Requirements:
|
|
1012
1009
|
/// - The wallet must be in the Live or MovingFunds or Closing or
|
|
1013
|
-
/// Terminated state
|
|
1010
|
+
/// Terminated state,
|
|
1014
1011
|
/// - The `walletPublicKey` and `sighash` calculated from
|
|
1015
|
-
/// `preimageSha256` must identify an open fraud challenge
|
|
1012
|
+
/// `preimageSha256` must identify an open fraud challenge,
|
|
1016
1013
|
/// - The expression `keccak256(abi.encode(walletMembersIDs))` must
|
|
1017
1014
|
/// be exactly the same as the hash stored under `membersIdsHash`
|
|
1018
1015
|
/// for the given `walletID`. Those IDs are not directly stored
|
|
1019
1016
|
/// in the contract for gas efficiency purposes but they can be
|
|
1020
1017
|
/// read from appropriate `DkgResultSubmitted` and `DkgResultApproved`
|
|
1021
|
-
/// events of the `WalletRegistry` contract
|
|
1018
|
+
/// events of the `WalletRegistry` contract,
|
|
1022
1019
|
/// - The amount of time indicated by `challengeDefeatTimeout` must pass
|
|
1023
|
-
/// after the challenge was reported
|
|
1020
|
+
/// after the challenge was reported.
|
|
1024
1021
|
function notifyFraudChallengeDefeatTimeout(
|
|
1025
1022
|
bytes calldata walletPublicKey,
|
|
1026
1023
|
uint32[] calldata walletMembersIDs,
|
|
@@ -1037,14 +1034,14 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
1037
1034
|
/// or no longer trusted. Vaults are not trusted by default.
|
|
1038
1035
|
/// Trusted vault must meet the following criteria:
|
|
1039
1036
|
/// - `IVault.receiveBalanceIncrease` must have a known, low gas
|
|
1040
|
-
/// cost
|
|
1037
|
+
/// cost,
|
|
1041
1038
|
/// - `IVault.receiveBalanceIncrease` must never revert.
|
|
1042
1039
|
/// @dev Without restricting reveal only to trusted vaults, malicious
|
|
1043
1040
|
/// vaults not meeting the criteria would be able to nuke sweep proof
|
|
1044
1041
|
/// transactions executed by ECDSA wallet with deposits routed to
|
|
1045
1042
|
/// them.
|
|
1046
|
-
/// @param vault The address of the vault
|
|
1047
|
-
/// @param isTrusted flag indicating whether the vault is trusted or not
|
|
1043
|
+
/// @param vault The address of the vault.
|
|
1044
|
+
/// @param isTrusted flag indicating whether the vault is trusted or not.
|
|
1048
1045
|
/// @dev Can only be called by the Governance.
|
|
1049
1046
|
function setVaultStatus(address vault, bool isTrusted)
|
|
1050
1047
|
external
|
|
@@ -1060,7 +1057,7 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
1060
1057
|
//// deposit. Value of this parameter must take into account the value
|
|
1061
1058
|
/// of `depositTreasuryFeeDivisor` and `depositTxMaxFee` parameters
|
|
1062
1059
|
/// in order to make requests that can incur the treasury and
|
|
1063
|
-
/// transaction fee and still satisfy the depositor
|
|
1060
|
+
/// transaction fee and still satisfy the depositor.
|
|
1064
1061
|
/// @param depositTreasuryFeeDivisor New value of the treasury fee divisor.
|
|
1065
1062
|
/// It is the divisor used to compute the treasury fee taken from
|
|
1066
1063
|
/// each deposit and transferred to the treasury upon sweep proof
|
|
@@ -1068,16 +1065,16 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
1068
1065
|
/// `treasuryFee = depositedAmount / depositTreasuryFeeDivisor`
|
|
1069
1066
|
/// For example, if the treasury fee needs to be 2% of each deposit,
|
|
1070
1067
|
/// the `depositTreasuryFeeDivisor` should be set to `50`
|
|
1071
|
-
/// because `1/50 = 0.02 = 2
|
|
1068
|
+
/// because `1/50 = 0.02 = 2%`.
|
|
1072
1069
|
/// @param depositTxMaxFee New value of the deposit tx max fee in satoshis.
|
|
1073
1070
|
/// It is the maximum amount of BTC transaction fee that can
|
|
1074
1071
|
/// be incurred by each swept deposit being part of the given sweep
|
|
1075
1072
|
/// transaction. If the maximum BTC transaction fee is exceeded,
|
|
1076
|
-
/// such transaction is considered a fraud
|
|
1073
|
+
/// such transaction is considered a fraud.
|
|
1077
1074
|
/// @dev Requirements:
|
|
1078
|
-
/// - Deposit dust threshold must be greater than zero
|
|
1079
|
-
/// - Deposit treasury fee divisor must be greater than zero
|
|
1080
|
-
/// - Deposit transaction max fee must be greater than zero
|
|
1075
|
+
/// - Deposit dust threshold must be greater than zero,
|
|
1076
|
+
/// - Deposit treasury fee divisor must be greater than zero,
|
|
1077
|
+
/// - Deposit transaction max fee must be greater than zero.
|
|
1081
1078
|
function updateDepositParameters(
|
|
1082
1079
|
uint64 depositDustThreshold,
|
|
1083
1080
|
uint64 depositTreasuryFeeDivisor,
|
|
@@ -1122,20 +1119,20 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
1122
1119
|
/// redeemer in full amount.
|
|
1123
1120
|
/// @param redemptionTimeoutSlashingAmount New value of the redemption
|
|
1124
1121
|
/// timeout slashing amount in T, it is the amount slashed from each
|
|
1125
|
-
/// wallet member for redemption timeout
|
|
1122
|
+
/// wallet member for redemption timeout.
|
|
1126
1123
|
/// @param redemptionTimeoutNotifierRewardMultiplier New value of the
|
|
1127
1124
|
/// redemption timeout notifier reward multiplier as percentage,
|
|
1128
1125
|
/// it determines the percentage of the notifier reward from the
|
|
1129
1126
|
/// staking contact the notifier of a redemption timeout receives.
|
|
1130
|
-
/// The value must be in the range [0, 100]
|
|
1127
|
+
/// The value must be in the range [0, 100].
|
|
1131
1128
|
/// @dev Requirements:
|
|
1132
1129
|
/// - Redemption dust threshold must be greater than moving funds dust
|
|
1133
|
-
/// threshold
|
|
1134
|
-
/// - Redemption treasury fee divisor must be greater than zero
|
|
1135
|
-
/// - Redemption transaction max fee must be greater than zero
|
|
1136
|
-
/// - Redemption timeout must be greater than zero
|
|
1130
|
+
/// threshold,
|
|
1131
|
+
/// - Redemption treasury fee divisor must be greater than zero,
|
|
1132
|
+
/// - Redemption transaction max fee must be greater than zero,
|
|
1133
|
+
/// - Redemption timeout must be greater than zero,
|
|
1137
1134
|
/// - Redemption timeout notifier reward multiplier must be in the
|
|
1138
|
-
/// range [0, 100]
|
|
1135
|
+
/// range [0, 100].
|
|
1139
1136
|
function updateRedemptionParameters(
|
|
1140
1137
|
uint64 redemptionDustThreshold,
|
|
1141
1138
|
uint64 redemptionTreasuryFeeDivisor,
|
|
@@ -1173,12 +1170,12 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
1173
1170
|
/// MovingFunds state.
|
|
1174
1171
|
/// @param movingFundsTimeoutSlashingAmount New value of the moving funds
|
|
1175
1172
|
/// timeout slashing amount in T, it is the amount slashed from each
|
|
1176
|
-
/// wallet member for moving funds timeout
|
|
1173
|
+
/// wallet member for moving funds timeout.
|
|
1177
1174
|
/// @param movingFundsTimeoutNotifierRewardMultiplier New value of the
|
|
1178
1175
|
/// moving funds timeout notifier reward multiplier as percentage,
|
|
1179
1176
|
/// it determines the percentage of the notifier reward from the
|
|
1180
1177
|
/// staking contact the notifier of a moving funds timeout receives.
|
|
1181
|
-
/// The value must be in the range [0, 100]
|
|
1178
|
+
/// The value must be in the range [0, 100].
|
|
1182
1179
|
/// @param movedFundsSweepTxMaxTotalFee New value of the moved funds sweep
|
|
1183
1180
|
/// transaction max total fee in satoshis. It is the maximum amount
|
|
1184
1181
|
/// of the total BTC transaction fee that is acceptable in a single
|
|
@@ -1191,23 +1188,23 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
1191
1188
|
/// funds.
|
|
1192
1189
|
/// @param movedFundsSweepTimeoutSlashingAmount New value of the moved
|
|
1193
1190
|
/// funds sweep timeout slashing amount in T, it is the amount
|
|
1194
|
-
/// slashed from each wallet member for moved funds sweep timeout
|
|
1191
|
+
/// slashed from each wallet member for moved funds sweep timeout.
|
|
1195
1192
|
/// @param movedFundsSweepTimeoutNotifierRewardMultiplier New value of
|
|
1196
1193
|
/// the moved funds sweep timeout notifier reward multiplier as
|
|
1197
1194
|
/// percentage, it determines the percentage of the notifier reward
|
|
1198
1195
|
/// from the staking contact the notifier of a moved funds sweep
|
|
1199
|
-
/// timeout receives. The value must be in the range [0, 100]
|
|
1196
|
+
/// timeout receives. The value must be in the range [0, 100].
|
|
1200
1197
|
/// @dev Requirements:
|
|
1201
|
-
/// - Moving funds transaction max total fee must be greater than zero
|
|
1198
|
+
/// - Moving funds transaction max total fee must be greater than zero,
|
|
1202
1199
|
/// - Moving funds dust threshold must be greater than zero and lower
|
|
1203
|
-
/// than the redemption dust threshold
|
|
1204
|
-
/// - Moving funds timeout must be greater than zero
|
|
1200
|
+
/// than the redemption dust threshold,
|
|
1201
|
+
/// - Moving funds timeout must be greater than zero,
|
|
1205
1202
|
/// - Moving funds timeout notifier reward multiplier must be in the
|
|
1206
|
-
/// range [0, 100]
|
|
1207
|
-
/// - Moved funds sweep transaction max total fee must be greater than zero
|
|
1208
|
-
/// - Moved funds sweep timeout must be greater than zero
|
|
1203
|
+
/// range [0, 100],
|
|
1204
|
+
/// - Moved funds sweep transaction max total fee must be greater than zero,
|
|
1205
|
+
/// - Moved funds sweep timeout must be greater than zero,
|
|
1209
1206
|
/// - Moved funds sweep timeout notifier reward multiplier must be in the
|
|
1210
|
-
/// range [0, 100]
|
|
1207
|
+
/// range [0, 100].
|
|
1211
1208
|
function updateMovingFundsParameters(
|
|
1212
1209
|
uint64 movingFundsTxMaxTotalFee,
|
|
1213
1210
|
uint64 movingFundsDustThreshold,
|
|
@@ -1235,29 +1232,29 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
1235
1232
|
/// @notice Updates parameters of wallets.
|
|
1236
1233
|
/// @param walletCreationPeriod New value of the wallet creation period in
|
|
1237
1234
|
/// seconds, determines how frequently a new wallet creation can be
|
|
1238
|
-
/// requested
|
|
1235
|
+
/// requested.
|
|
1239
1236
|
/// @param walletCreationMinBtcBalance New value of the wallet minimum BTC
|
|
1240
|
-
/// balance in satoshi, used to decide about wallet creation
|
|
1237
|
+
/// balance in satoshi, used to decide about wallet creation.
|
|
1241
1238
|
/// @param walletCreationMaxBtcBalance New value of the wallet maximum BTC
|
|
1242
|
-
/// balance in satoshi, used to decide about wallet creation
|
|
1239
|
+
/// balance in satoshi, used to decide about wallet creation.
|
|
1243
1240
|
/// @param walletClosureMinBtcBalance New value of the wallet minimum BTC
|
|
1244
|
-
/// balance in satoshi, used to decide about wallet closure
|
|
1241
|
+
/// balance in satoshi, used to decide about wallet closure.
|
|
1245
1242
|
/// @param walletMaxAge New value of the wallet maximum age in seconds,
|
|
1246
1243
|
/// indicates the maximum age of a wallet in seconds, after which
|
|
1247
|
-
/// the wallet moving funds process can be requested
|
|
1244
|
+
/// the wallet moving funds process can be requested.
|
|
1248
1245
|
/// @param walletMaxBtcTransfer New value of the wallet maximum BTC transfer
|
|
1249
1246
|
/// in satoshi, determines the maximum amount that can be transferred
|
|
1250
|
-
// to a single target wallet during the moving funds process
|
|
1247
|
+
// to a single target wallet during the moving funds process.
|
|
1251
1248
|
/// @param walletClosingPeriod New value of the wallet closing period in
|
|
1252
1249
|
/// seconds, determines the length of the wallet closing period,
|
|
1253
1250
|
// i.e. the period when the wallet remains in the Closing state
|
|
1254
|
-
// and can be subject of deposit fraud challenges
|
|
1251
|
+
// and can be subject of deposit fraud challenges.
|
|
1255
1252
|
/// @dev Requirements:
|
|
1256
|
-
/// - Wallet minimum BTC balance must be greater than zero
|
|
1253
|
+
/// - Wallet minimum BTC balance must be greater than zero,
|
|
1257
1254
|
/// - Wallet maximum BTC balance must be greater than the wallet
|
|
1258
|
-
/// minimum BTC balance
|
|
1259
|
-
/// - Wallet maximum BTC transfer must be greater than zero
|
|
1260
|
-
/// - Wallet closing period must be greater than zero
|
|
1255
|
+
/// minimum BTC balance,
|
|
1256
|
+
/// - Wallet maximum BTC transfer must be greater than zero,
|
|
1257
|
+
/// - Wallet closing period must be greater than zero.
|
|
1261
1258
|
function updateWalletParameters(
|
|
1262
1259
|
uint32 walletCreationPeriod,
|
|
1263
1260
|
uint64 walletCreationMinBtcBalance,
|
|
@@ -1281,20 +1278,20 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
1281
1278
|
/// @notice Updates parameters related to frauds.
|
|
1282
1279
|
/// @param fraudChallengeDepositAmount New value of the fraud challenge
|
|
1283
1280
|
/// deposit amount in wei, it is the amount of ETH the party
|
|
1284
|
-
/// challenging the wallet for fraud needs to deposit
|
|
1281
|
+
/// challenging the wallet for fraud needs to deposit.
|
|
1285
1282
|
/// @param fraudChallengeDefeatTimeout New value of the challenge defeat
|
|
1286
1283
|
/// timeout in seconds, it is the amount of time the wallet has to
|
|
1287
|
-
/// defeat a fraud challenge. The value must be greater than zero
|
|
1284
|
+
/// defeat a fraud challenge. The value must be greater than zero.
|
|
1288
1285
|
/// @param fraudSlashingAmount New value of the fraud slashing amount in T,
|
|
1289
1286
|
/// it is the amount slashed from each wallet member for committing
|
|
1290
|
-
/// a fraud
|
|
1287
|
+
/// a fraud.
|
|
1291
1288
|
/// @param fraudNotifierRewardMultiplier New value of the fraud notifier
|
|
1292
1289
|
/// reward multiplier as percentage, it determines the percentage of
|
|
1293
1290
|
/// the notifier reward from the staking contact the notifier of
|
|
1294
|
-
/// a fraud receives. The value must be in the range [0, 100]
|
|
1291
|
+
/// a fraud receives. The value must be in the range [0, 100].
|
|
1295
1292
|
/// @dev Requirements:
|
|
1296
|
-
/// - Fraud challenge defeat timeout must be greater than 0
|
|
1297
|
-
/// - Fraud notifier reward multiplier must be in the range [0, 100]
|
|
1293
|
+
/// - Fraud challenge defeat timeout must be greater than 0,
|
|
1294
|
+
/// - Fraud notifier reward multiplier must be in the range [0, 100].
|
|
1298
1295
|
function updateFraudParameters(
|
|
1299
1296
|
uint256 fraudChallengeDepositAmount,
|
|
1300
1297
|
uint256 fraudChallengeDefeatTimeout,
|
|
@@ -1334,9 +1331,9 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
1334
1331
|
/// to this mapping by the `requestRedemption` method (duplicates
|
|
1335
1332
|
/// not allowed) and are removed by one of the following methods:
|
|
1336
1333
|
/// - `submitRedemptionProof` in case the request was handled
|
|
1337
|
-
/// successfully
|
|
1334
|
+
/// successfully,
|
|
1338
1335
|
/// - `notifyRedemptionTimeout` in case the request was reported
|
|
1339
|
-
/// to be timed out
|
|
1336
|
+
/// to be timed out.
|
|
1340
1337
|
function pendingRedemptions(uint256 redemptionKey)
|
|
1341
1338
|
external
|
|
1342
1339
|
view
|
|
@@ -1378,7 +1375,7 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
1378
1375
|
|
|
1379
1376
|
/// @notice Gets details about a registered wallet.
|
|
1380
1377
|
/// @param walletPubKeyHash The 20-byte wallet public key hash (computed
|
|
1381
|
-
/// using Bitcoin HASH160 over the compressed ECDSA public key)
|
|
1378
|
+
/// using Bitcoin HASH160 over the compressed ECDSA public key).
|
|
1382
1379
|
/// @return Wallet details.
|
|
1383
1380
|
function wallets(bytes20 walletPubKeyHash)
|
|
1384
1381
|
external
|
|
@@ -1419,7 +1416,7 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
1419
1416
|
/// is actually an UTXO representing the moved funds and is supposed
|
|
1420
1417
|
/// to be swept with the current main UTXO of the recipient wallet.
|
|
1421
1418
|
/// @param requestKey Request key built as
|
|
1422
|
-
/// `keccak256(movingFundsTxHash | movingFundsOutputIndex)
|
|
1419
|
+
/// `keccak256(movingFundsTxHash | movingFundsOutputIndex)`.
|
|
1423
1420
|
/// @return Details of the moved funds sweep request.
|
|
1424
1421
|
function movedFundsSweepRequests(uint256 requestKey)
|
|
1425
1422
|
external
|