@keep-network/tbtc-v2 0.1.1-dev.81 → 0.1.1-dev.84
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 +16 -16
- package/artifacts/Bridge.json +33 -11
- package/artifacts/Deposit.json +7 -7
- package/artifacts/DepositSweep.json +7 -7
- package/artifacts/EcdsaDkgValidator.json +1 -1
- package/artifacts/EcdsaInactivity.json +1 -1
- package/artifacts/EcdsaSortitionPool.json +2 -2
- package/artifacts/Fraud.json +7 -7
- 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 +7 -7
- package/artifacts/NuCypherStakingEscrow.json +1 -1
- package/artifacts/NuCypherToken.json +2 -2
- package/artifacts/RandomBeaconStub.json +1 -1
- package/artifacts/Redemption.json +26 -14
- package/artifacts/ReimbursementPool.json +2 -2
- package/artifacts/Relay.json +11 -11
- package/artifacts/T.json +2 -2
- package/artifacts/TBTC.json +13 -13
- package/artifacts/TBTCToken.json +13 -13
- package/artifacts/TBTCVault.json +71 -42
- package/artifacts/TokenStaking.json +1 -1
- package/artifacts/TokenholderGovernor.json +9 -9
- package/artifacts/TokenholderTimelock.json +8 -8
- package/artifacts/VendingMachine.json +11 -11
- package/artifacts/VendingMachineKeep.json +1 -1
- package/artifacts/VendingMachineNuCypher.json +1 -1
- package/artifacts/WalletRegistry.json +5 -5
- package/artifacts/WalletRegistryGovernance.json +2 -2
- package/artifacts/Wallets.json +9 -9
- package/artifacts/solcInputs/{3f679eb4591b969794b6013bc0d8da70.json → 0f79d51f4c2e0d6bf7d919933c677b91.json} +12 -9
- package/build/contracts/GovernanceUtils.sol/GovernanceUtils.dbg.json +1 -1
- package/build/contracts/bank/Bank.sol/Bank.dbg.json +1 -1
- package/build/contracts/bank/Bank.sol/Bank.json +2 -2
- package/build/contracts/bank/IReceiveBalanceApproval.sol/IReceiveBalanceApproval.dbg.json +1 -1
- 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 +73 -42
- 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/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/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 +35 -17
- package/contracts/bank/Bank.sol +1 -1
- package/contracts/bank/IReceiveBalanceApproval.sol +2 -2
- package/contracts/bridge/BitcoinTx.sol +1 -1
- package/contracts/bridge/Bridge.sol +85 -6
- package/contracts/bridge/Redemption.sol +160 -6
- package/contracts/vault/TBTCVault.sol +57 -19
- package/export.json +55 -15
- package/package.json +1 -1
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"type": "uint256"
|
|
74
74
|
}
|
|
75
75
|
],
|
|
76
|
-
"name": "
|
|
76
|
+
"name": "Unminted",
|
|
77
77
|
"type": "event"
|
|
78
78
|
},
|
|
79
79
|
{
|
|
@@ -134,7 +134,7 @@
|
|
|
134
134
|
},
|
|
135
135
|
{
|
|
136
136
|
"internalType": "bytes",
|
|
137
|
-
"name": "",
|
|
137
|
+
"name": "extraData",
|
|
138
138
|
"type": "bytes"
|
|
139
139
|
}
|
|
140
140
|
],
|
|
@@ -235,19 +235,6 @@
|
|
|
235
235
|
"stateMutability": "nonpayable",
|
|
236
236
|
"type": "function"
|
|
237
237
|
},
|
|
238
|
-
{
|
|
239
|
-
"inputs": [
|
|
240
|
-
{
|
|
241
|
-
"internalType": "uint256",
|
|
242
|
-
"name": "amount",
|
|
243
|
-
"type": "uint256"
|
|
244
|
-
}
|
|
245
|
-
],
|
|
246
|
-
"name": "redeem",
|
|
247
|
-
"outputs": [],
|
|
248
|
-
"stateMutability": "nonpayable",
|
|
249
|
-
"type": "function"
|
|
250
|
-
},
|
|
251
238
|
{
|
|
252
239
|
"inputs": [],
|
|
253
240
|
"name": "tbtcToken",
|
|
@@ -273,10 +260,41 @@
|
|
|
273
260
|
"outputs": [],
|
|
274
261
|
"stateMutability": "nonpayable",
|
|
275
262
|
"type": "function"
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
"inputs": [
|
|
266
|
+
{
|
|
267
|
+
"internalType": "uint256",
|
|
268
|
+
"name": "amount",
|
|
269
|
+
"type": "uint256"
|
|
270
|
+
}
|
|
271
|
+
],
|
|
272
|
+
"name": "unmint",
|
|
273
|
+
"outputs": [],
|
|
274
|
+
"stateMutability": "nonpayable",
|
|
275
|
+
"type": "function"
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
"inputs": [
|
|
279
|
+
{
|
|
280
|
+
"internalType": "uint256",
|
|
281
|
+
"name": "amount",
|
|
282
|
+
"type": "uint256"
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
"internalType": "bytes",
|
|
286
|
+
"name": "redemptionData",
|
|
287
|
+
"type": "bytes"
|
|
288
|
+
}
|
|
289
|
+
],
|
|
290
|
+
"name": "unmintAndRedeem",
|
|
291
|
+
"outputs": [],
|
|
292
|
+
"stateMutability": "nonpayable",
|
|
293
|
+
"type": "function"
|
|
276
294
|
}
|
|
277
295
|
],
|
|
278
|
-
"bytecode": "
|
|
279
|
-
"deployedBytecode": "
|
|
296
|
+
"bytecode": "0x60806040523480156200001157600080fd5b506040516200133c3803806200133c8339810160408190526200003491620001b4565b6001600160a01b038216620000905760405162461bcd60e51b815260206004820181905260248201527f42616e6b2063616e206e6f7420626520746865207a65726f206164647265737360448201526064015b60405180910390fd5b6001600160a01b038116620000f75760405162461bcd60e51b815260206004820152602660248201527f5442544320746f6b656e2063616e206e6f7420626520746865207a65726f206160448201526564647265737360d01b606482015260840162000087565b603280546001600160a01b038085166001600160a01b031992831617909255603380549284169290911691909117905562000132336200013a565b5050620001f3565b600080546001600160a01b038381166001600160a01b031983168117909355604080519190921680825260208201939093527f5f56bee8cffbe9a78652a74a60705edede02af10b0bbb888ca44b79a0d42ce80910160405180910390a15050565b6001600160a01b0381168114620001b157600080fd5b50565b60008060408385031215620001c857600080fd5b8251620001d5816200019b565b6020840151909250620001e8816200019b565b809150509250929050565b61113980620002036000396000f3fe608060405234801561001057600080fd5b50600436106100d45760003560e01c806376cdb03b11610081578063d38bfff41161005b578063d38bfff4146101a2578063e5d3d714146101b5578063fc4e51f6146101c857600080fd5b806376cdb03b146101695780638f4ffcb11461017c578063a0712d681461018f57600080fd5b806353dce4df116100b257806353dce4df146101145780635aa6e6751461012757806364e779b11461015657600080fd5b80631171bda9146100d9578063461c6373146100ee578063475d057014610101575b600080fd5b6100ec6100e7366004610d17565b6101db565b005b6100ec6100fc366004610da4565b6102c6565b6100ec61010f366004610e52565b6103d9565b6100ec610122366004610ea2565b610586565b60005461013a906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b6100ec610164366004610eee565b610597565b60325461013a906001600160a01b031681565b6100ec61018a366004610f07565b6105a4565b6100ec61019d366004610eee565b610679565b6100ec6101b0366004610f7a565b6107cd565b60335461013a906001600160a01b031681565b6100ec6101d6366004610f9e565b6108ac565b6000546001600160a01b0316331461023a5760405162461bcd60e51b815260206004820152601c60248201527f43616c6c6572206973206e6f742074686520676f7665726e616e63650000000060448201526064015b60405180910390fd5b6033546040517f1171bda90000000000000000000000000000000000000000000000000000000081526001600160a01b03858116600483015284811660248301526044820184905290911690631171bda990606401600060405180830381600087803b1580156102a957600080fd5b505af11580156102bd573d6000803e3d6000fd5b50505050505050565b6032546001600160a01b031633146103205760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f74207468652042616e6b000000000000000000006044820152606401610231565b8261036d5760405162461bcd60e51b815260206004820152601760248201527f4e6f206465706f7369746f7273207370656369666965640000000000000000006044820152606401610231565b60005b838110156103d2576103c085858381811061038d5761038d610ff4565b90506020020160208101906103a29190610f7a565b8484848181106103b4576103b4610ff4565b90506020020135610990565b806103ca8161100a565b915050610370565b5050505050565b6032546001600160a01b031633146104335760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f74207468652042616e6b000000000000000000006044820152606401610231565b6032546040516370a0823160e01b81526001600160a01b038681166004830152859216906370a082319060240160206040518083038186803b15801561047857600080fd5b505afa15801561048c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104b09190611033565b10156105095760405162461bcd60e51b815260206004820152602260248201527f416d6f756e7420657863656564732062616c616e636520696e207468652062616044820152616e6b60f01b6064820152608401610231565b6105138484610990565b603254604051631f1b6d2760e21b81526001600160a01b0386811660048301523060248301526044820186905290911690637c6db49c906064015b600060405180830381600087803b15801561056857600080fd5b505af115801561057c573d6000803e3d6000fd5b5050505050505050565b61059233848484610a25565b505050565b6105a13382610b8e565b50565b6033546001600160a01b038481169116146106015760405162461bcd60e51b815260206004820152601160248201527f546f6b656e206973206e6f7420544254430000000000000000000000000000006044820152606401610231565b336001600160a01b038416146106595760405162461bcd60e51b815260206004820152601860248201527f4f6e6c7920544254432063616c6c657220616c6c6f77656400000000000000006044820152606401610231565b8061066d576106688585610b8e565b6103d2565b6103d285858484610a25565b6032546040516370a0823160e01b815233600482018190529183916001600160a01b03909116906370a082319060240160206040518083038186803b1580156106c157600080fd5b505afa1580156106d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106f99190611033565b10156107525760405162461bcd60e51b815260206004820152602260248201527f416d6f756e7420657863656564732062616c616e636520696e207468652062616044820152616e6b60f01b6064820152608401610231565b61075c8183610990565b603254604051631f1b6d2760e21b81526001600160a01b0383811660048301523060248301526044820185905290911690637c6db49c906064015b600060405180830381600087803b1580156107b157600080fd5b505af11580156107c5573d6000803e3d6000fd5b505050505050565b6000546001600160a01b031633146108275760405162461bcd60e51b815260206004820152601c60248201527f43616c6c6572206973206e6f742074686520676f7665726e616e6365000000006044820152606401610231565b6001600160a01b0381166108a35760405162461bcd60e51b815260206004820152602260248201527f4e657720676f7665726e616e636520697320746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152608401610231565b6105a181610c89565b6000546001600160a01b031633146109065760405162461bcd60e51b815260206004820152601c60248201527f43616c6c6572206973206e6f742074686520676f7665726e616e6365000000006044820152606401610231565b6033546040517ffc4e51f60000000000000000000000000000000000000000000000000000000081526001600160a01b039091169063fc4e51f6906109579088908890889088908890600401611075565b600060405180830381600087803b15801561097157600080fd5b505af1158015610985573d6000803e3d6000fd5b505050505050505050565b816001600160a01b03167f30385c845b448a36257a6a1716e6ad2e1bc2cbe333cde1e69fe849ad6511adfe826040516109cb91815260200190565b60405180910390a26033546040517f40c10f190000000000000000000000000000000000000000000000000000000081526001600160a01b03848116600483015260248201849052909116906340c10f1990604401610797565b836001600160a01b03167f68751a4c3821398cb63d11609eca2440742ef19446f0c0261bfa8a13dd0748b884604051610a6091815260200190565b60405180910390a260335460405163079cc67960e41b81526001600160a01b03868116600483015260248201869052909116906379cc679090604401600060405180830381600087803b158015610ab657600080fd5b505af1158015610aca573d6000803e3d6000fd5b5050603254604080517fe78cea9200000000000000000000000000000000000000000000000000000000815290516001600160a01b039092169350634a38757e9250839163e78cea9291600480820192602092909190829003018186803b158015610b3457600080fd5b505afa158015610b48573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b6c91906110b3565b8585856040518563ffffffff1660e01b815260040161054e94939291906110d0565b816001600160a01b03167f68751a4c3821398cb63d11609eca2440742ef19446f0c0261bfa8a13dd0748b882604051610bc991815260200190565b60405180910390a260335460405163079cc67960e41b81526001600160a01b03848116600483015260248201849052909116906379cc679090604401600060405180830381600087803b158015610c1f57600080fd5b505af1158015610c33573d6000803e3d6000fd5b50506032546040517f56a6d9ef0000000000000000000000000000000000000000000000000000000081526001600160a01b0386811660048301526024820186905290911692506356a6d9ef9150604401610797565b600080546001600160a01b038381167fffffffffffffffffffffffff000000000000000000000000000000000000000083168117909355604080519190921680825260208201939093527f5f56bee8cffbe9a78652a74a60705edede02af10b0bbb888ca44b79a0d42ce80910160405180910390a15050565b6001600160a01b03811681146105a157600080fd5b600080600060608486031215610d2c57600080fd5b8335610d3781610d02565b92506020840135610d4781610d02565b929592945050506040919091013590565b60008083601f840112610d6a57600080fd5b50813567ffffffffffffffff811115610d8257600080fd5b6020830191508360208260051b8501011115610d9d57600080fd5b9250929050565b60008060008060408587031215610dba57600080fd5b843567ffffffffffffffff80821115610dd257600080fd5b610dde88838901610d58565b90965094506020870135915080821115610df757600080fd5b50610e0487828801610d58565b95989497509550505050565b60008083601f840112610e2257600080fd5b50813567ffffffffffffffff811115610e3a57600080fd5b602083019150836020828501011115610d9d57600080fd5b60008060008060608587031215610e6857600080fd5b8435610e7381610d02565b935060208501359250604085013567ffffffffffffffff811115610e9657600080fd5b610e0487828801610e10565b600080600060408486031215610eb757600080fd5b83359250602084013567ffffffffffffffff811115610ed557600080fd5b610ee186828701610e10565b9497909650939450505050565b600060208284031215610f0057600080fd5b5035919050565b600080600080600060808688031215610f1f57600080fd5b8535610f2a81610d02565b9450602086013593506040860135610f4181610d02565b9250606086013567ffffffffffffffff811115610f5d57600080fd5b610f6988828901610e10565b969995985093965092949392505050565b600060208284031215610f8c57600080fd5b8135610f9781610d02565b9392505050565b600080600080600060808688031215610fb657600080fd5b8535610fc181610d02565b94506020860135610fd181610d02565b935060408601359250606086013567ffffffffffffffff811115610f5d57600080fd5b634e487b7160e01b600052603260045260246000fd5b600060001982141561102c57634e487b7160e01b600052601160045260246000fd5b5060010190565b60006020828403121561104557600080fd5b5051919050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b60006001600160a01b038088168352808716602084015250846040830152608060608301526110a860808301848661104c565b979650505050505050565b6000602082840312156110c557600080fd5b8151610f9781610d02565b6001600160a01b03851681528360208201526060604082015260006110f960608301848661104c565b969550505050505056fea2646970667358221220d2cfb91930afdd275bc94b23bee0885041e8e6f33971c1a8d00e04c1b5b1ccf064736f6c63430008090033",
|
|
297
|
+
"deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100d45760003560e01c806376cdb03b11610081578063d38bfff41161005b578063d38bfff4146101a2578063e5d3d714146101b5578063fc4e51f6146101c857600080fd5b806376cdb03b146101695780638f4ffcb11461017c578063a0712d681461018f57600080fd5b806353dce4df116100b257806353dce4df146101145780635aa6e6751461012757806364e779b11461015657600080fd5b80631171bda9146100d9578063461c6373146100ee578063475d057014610101575b600080fd5b6100ec6100e7366004610d17565b6101db565b005b6100ec6100fc366004610da4565b6102c6565b6100ec61010f366004610e52565b6103d9565b6100ec610122366004610ea2565b610586565b60005461013a906001600160a01b031681565b6040516001600160a01b03909116815260200160405180910390f35b6100ec610164366004610eee565b610597565b60325461013a906001600160a01b031681565b6100ec61018a366004610f07565b6105a4565b6100ec61019d366004610eee565b610679565b6100ec6101b0366004610f7a565b6107cd565b60335461013a906001600160a01b031681565b6100ec6101d6366004610f9e565b6108ac565b6000546001600160a01b0316331461023a5760405162461bcd60e51b815260206004820152601c60248201527f43616c6c6572206973206e6f742074686520676f7665726e616e63650000000060448201526064015b60405180910390fd5b6033546040517f1171bda90000000000000000000000000000000000000000000000000000000081526001600160a01b03858116600483015284811660248301526044820184905290911690631171bda990606401600060405180830381600087803b1580156102a957600080fd5b505af11580156102bd573d6000803e3d6000fd5b50505050505050565b6032546001600160a01b031633146103205760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f74207468652042616e6b000000000000000000006044820152606401610231565b8261036d5760405162461bcd60e51b815260206004820152601760248201527f4e6f206465706f7369746f7273207370656369666965640000000000000000006044820152606401610231565b60005b838110156103d2576103c085858381811061038d5761038d610ff4565b90506020020160208101906103a29190610f7a565b8484848181106103b4576103b4610ff4565b90506020020135610990565b806103ca8161100a565b915050610370565b5050505050565b6032546001600160a01b031633146104335760405162461bcd60e51b815260206004820152601660248201527f43616c6c6572206973206e6f74207468652042616e6b000000000000000000006044820152606401610231565b6032546040516370a0823160e01b81526001600160a01b038681166004830152859216906370a082319060240160206040518083038186803b15801561047857600080fd5b505afa15801561048c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104b09190611033565b10156105095760405162461bcd60e51b815260206004820152602260248201527f416d6f756e7420657863656564732062616c616e636520696e207468652062616044820152616e6b60f01b6064820152608401610231565b6105138484610990565b603254604051631f1b6d2760e21b81526001600160a01b0386811660048301523060248301526044820186905290911690637c6db49c906064015b600060405180830381600087803b15801561056857600080fd5b505af115801561057c573d6000803e3d6000fd5b5050505050505050565b61059233848484610a25565b505050565b6105a13382610b8e565b50565b6033546001600160a01b038481169116146106015760405162461bcd60e51b815260206004820152601160248201527f546f6b656e206973206e6f7420544254430000000000000000000000000000006044820152606401610231565b336001600160a01b038416146106595760405162461bcd60e51b815260206004820152601860248201527f4f6e6c7920544254432063616c6c657220616c6c6f77656400000000000000006044820152606401610231565b8061066d576106688585610b8e565b6103d2565b6103d285858484610a25565b6032546040516370a0823160e01b815233600482018190529183916001600160a01b03909116906370a082319060240160206040518083038186803b1580156106c157600080fd5b505afa1580156106d5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106f99190611033565b10156107525760405162461bcd60e51b815260206004820152602260248201527f416d6f756e7420657863656564732062616c616e636520696e207468652062616044820152616e6b60f01b6064820152608401610231565b61075c8183610990565b603254604051631f1b6d2760e21b81526001600160a01b0383811660048301523060248301526044820185905290911690637c6db49c906064015b600060405180830381600087803b1580156107b157600080fd5b505af11580156107c5573d6000803e3d6000fd5b505050505050565b6000546001600160a01b031633146108275760405162461bcd60e51b815260206004820152601c60248201527f43616c6c6572206973206e6f742074686520676f7665726e616e6365000000006044820152606401610231565b6001600160a01b0381166108a35760405162461bcd60e51b815260206004820152602260248201527f4e657720676f7665726e616e636520697320746865207a65726f20616464726560448201527f73730000000000000000000000000000000000000000000000000000000000006064820152608401610231565b6105a181610c89565b6000546001600160a01b031633146109065760405162461bcd60e51b815260206004820152601c60248201527f43616c6c6572206973206e6f742074686520676f7665726e616e6365000000006044820152606401610231565b6033546040517ffc4e51f60000000000000000000000000000000000000000000000000000000081526001600160a01b039091169063fc4e51f6906109579088908890889088908890600401611075565b600060405180830381600087803b15801561097157600080fd5b505af1158015610985573d6000803e3d6000fd5b505050505050505050565b816001600160a01b03167f30385c845b448a36257a6a1716e6ad2e1bc2cbe333cde1e69fe849ad6511adfe826040516109cb91815260200190565b60405180910390a26033546040517f40c10f190000000000000000000000000000000000000000000000000000000081526001600160a01b03848116600483015260248201849052909116906340c10f1990604401610797565b836001600160a01b03167f68751a4c3821398cb63d11609eca2440742ef19446f0c0261bfa8a13dd0748b884604051610a6091815260200190565b60405180910390a260335460405163079cc67960e41b81526001600160a01b03868116600483015260248201869052909116906379cc679090604401600060405180830381600087803b158015610ab657600080fd5b505af1158015610aca573d6000803e3d6000fd5b5050603254604080517fe78cea9200000000000000000000000000000000000000000000000000000000815290516001600160a01b039092169350634a38757e9250839163e78cea9291600480820192602092909190829003018186803b158015610b3457600080fd5b505afa158015610b48573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b6c91906110b3565b8585856040518563ffffffff1660e01b815260040161054e94939291906110d0565b816001600160a01b03167f68751a4c3821398cb63d11609eca2440742ef19446f0c0261bfa8a13dd0748b882604051610bc991815260200190565b60405180910390a260335460405163079cc67960e41b81526001600160a01b03848116600483015260248201849052909116906379cc679090604401600060405180830381600087803b158015610c1f57600080fd5b505af1158015610c33573d6000803e3d6000fd5b50506032546040517f56a6d9ef0000000000000000000000000000000000000000000000000000000081526001600160a01b0386811660048301526024820186905290911692506356a6d9ef9150604401610797565b600080546001600160a01b038381167fffffffffffffffffffffffff000000000000000000000000000000000000000083168117909355604080519190921680825260208201939093527f5f56bee8cffbe9a78652a74a60705edede02af10b0bbb888ca44b79a0d42ce80910160405180910390a15050565b6001600160a01b03811681146105a157600080fd5b600080600060608486031215610d2c57600080fd5b8335610d3781610d02565b92506020840135610d4781610d02565b929592945050506040919091013590565b60008083601f840112610d6a57600080fd5b50813567ffffffffffffffff811115610d8257600080fd5b6020830191508360208260051b8501011115610d9d57600080fd5b9250929050565b60008060008060408587031215610dba57600080fd5b843567ffffffffffffffff80821115610dd257600080fd5b610dde88838901610d58565b90965094506020870135915080821115610df757600080fd5b50610e0487828801610d58565b95989497509550505050565b60008083601f840112610e2257600080fd5b50813567ffffffffffffffff811115610e3a57600080fd5b602083019150836020828501011115610d9d57600080fd5b60008060008060608587031215610e6857600080fd5b8435610e7381610d02565b935060208501359250604085013567ffffffffffffffff811115610e9657600080fd5b610e0487828801610e10565b600080600060408486031215610eb757600080fd5b83359250602084013567ffffffffffffffff811115610ed557600080fd5b610ee186828701610e10565b9497909650939450505050565b600060208284031215610f0057600080fd5b5035919050565b600080600080600060808688031215610f1f57600080fd5b8535610f2a81610d02565b9450602086013593506040860135610f4181610d02565b9250606086013567ffffffffffffffff811115610f5d57600080fd5b610f6988828901610e10565b969995985093965092949392505050565b600060208284031215610f8c57600080fd5b8135610f9781610d02565b9392505050565b600080600080600060808688031215610fb657600080fd5b8535610fc181610d02565b94506020860135610fd181610d02565b935060408601359250606086013567ffffffffffffffff811115610f5d57600080fd5b634e487b7160e01b600052603260045260246000fd5b600060001982141561102c57634e487b7160e01b600052601160045260246000fd5b5060010190565b60006020828403121561104557600080fd5b5051919050565b81835281816020850137506000828201602090810191909152601f909101601f19169091010190565b60006001600160a01b038088168352808716602084015250846040830152608060608301526110a860808301848661104c565b979650505050505050565b6000602082840312156110c557600080fd5b8151610f9781610d02565b6001600160a01b03851681528360208201526060604082015260006110f960608301848661104c565b969550505050505056fea2646970667358221220d2cfb91930afdd275bc94b23bee0885041e8e6f33971c1a8d00e04c1b5b1ccf064736f6c63430008090033",
|
|
280
298
|
"linkReferences": {},
|
|
281
299
|
"deployedLinkReferences": {}
|
|
282
300
|
}
|
package/contracts/bank/Bank.sol
CHANGED
|
@@ -141,7 +141,7 @@ contract Bank is Ownable {
|
|
|
141
141
|
function approveBalanceAndCall(
|
|
142
142
|
address spender,
|
|
143
143
|
uint256 amount,
|
|
144
|
-
bytes
|
|
144
|
+
bytes calldata extraData
|
|
145
145
|
) external {
|
|
146
146
|
_approveBalance(msg.sender, spender, amount);
|
|
147
147
|
IReceiveBalanceApproval(spender).receiveBalanceApproval(
|
|
@@ -30,7 +30,7 @@ interface IReceiveBalanceApproval {
|
|
|
30
30
|
/// @param amount The amount of the Bank balance approved by the owner
|
|
31
31
|
/// to be used by the contract.
|
|
32
32
|
/// @param extraData The `extraData` passed to `Bank.approveBalanceAndCall`.
|
|
33
|
-
|
|
33
|
+
/// @dev The implementation must ensure this function can only be called
|
|
34
34
|
/// by the Bank. The Bank does _not_ guarantee that the `amount`
|
|
35
35
|
/// approved by the `owner` currently exists on their balance. That is,
|
|
36
36
|
/// the `owner` could approve more balance than they currently have.
|
|
@@ -40,6 +40,6 @@ interface IReceiveBalanceApproval {
|
|
|
40
40
|
function receiveBalanceApproval(
|
|
41
41
|
address owner,
|
|
42
42
|
uint256 amount,
|
|
43
|
-
bytes
|
|
43
|
+
bytes calldata extraData
|
|
44
44
|
) external;
|
|
45
45
|
}
|
|
@@ -266,7 +266,7 @@ library BitcoinTx {
|
|
|
266
266
|
/// on a 20-byte public key hash.
|
|
267
267
|
function extractPubKeyHash(BridgeState.Storage storage, bytes memory output)
|
|
268
268
|
internal
|
|
269
|
-
|
|
269
|
+
pure
|
|
270
270
|
returns (bytes20 pubKeyHash)
|
|
271
271
|
{
|
|
272
272
|
bytes memory pubKeyHashBytes = output.extractHash();
|
|
@@ -19,6 +19,7 @@ import "@keep-network/random-beacon/contracts/Governable.sol";
|
|
|
19
19
|
import {IWalletOwner as EcdsaWalletOwner} from "@keep-network/ecdsa/contracts/api/IWalletOwner.sol";
|
|
20
20
|
|
|
21
21
|
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
|
|
22
|
+
import "@openzeppelin/contracts-upgradeable/utils/math/SafeCastUpgradeable.sol";
|
|
22
23
|
|
|
23
24
|
import "./IRelay.sol";
|
|
24
25
|
import "./BridgeState.sol";
|
|
@@ -31,6 +32,7 @@ import "./Wallets.sol";
|
|
|
31
32
|
import "./Fraud.sol";
|
|
32
33
|
import "./MovingFunds.sol";
|
|
33
34
|
|
|
35
|
+
import "../bank/IReceiveBalanceApproval.sol";
|
|
34
36
|
import "../bank/Bank.sol";
|
|
35
37
|
|
|
36
38
|
/// @title Bitcoin Bridge
|
|
@@ -54,7 +56,12 @@ import "../bank/Bank.sol";
|
|
|
54
56
|
/// @dev Bridge is an upgradeable component of the Bank. The order of
|
|
55
57
|
/// functionalities in this contract is: deposit, sweep, redemption,
|
|
56
58
|
/// moving funds, wallet lifecycle, frauds, parameters.
|
|
57
|
-
contract Bridge is
|
|
59
|
+
contract Bridge is
|
|
60
|
+
Governable,
|
|
61
|
+
EcdsaWalletOwner,
|
|
62
|
+
Initializable,
|
|
63
|
+
IReceiveBalanceApproval
|
|
64
|
+
{
|
|
58
65
|
using BridgeState for BridgeState.Storage;
|
|
59
66
|
using Deposit for BridgeState.Storage;
|
|
60
67
|
using DepositSweep for BridgeState.Storage;
|
|
@@ -386,7 +393,9 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
386
393
|
}
|
|
387
394
|
|
|
388
395
|
/// @notice Requests redemption of the given amount from the specified
|
|
389
|
-
/// wallet to the redeemer Bitcoin output script.
|
|
396
|
+
/// wallet to the redeemer Bitcoin output script. Handles the
|
|
397
|
+
/// simplest case in which the redeemer's balance is decreased in
|
|
398
|
+
/// the Bank.
|
|
390
399
|
/// @param walletPubKeyHash The 20-byte wallet public key hash (computed
|
|
391
400
|
/// using Bitcoin HASH160 over the compressed ECDSA public key).
|
|
392
401
|
/// @param mainUtxo Data of the wallet's main UTXO, as currently known on
|
|
@@ -394,8 +403,8 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
394
403
|
/// @param redeemerOutputScript The redeemer's length-prefixed output
|
|
395
404
|
/// script (P2PKH, P2WPKH, P2SH or P2WSH) that will be used to lock
|
|
396
405
|
/// redeemed BTC.
|
|
397
|
-
/// @param amount Requested amount in satoshi. This is also the
|
|
398
|
-
/// that is taken from
|
|
406
|
+
/// @param amount Requested amount in satoshi. This is also the Bank balance
|
|
407
|
+
/// that is taken from the `balanceOwner` upon request.
|
|
399
408
|
/// Once the request is handled, the actual amount of BTC locked
|
|
400
409
|
/// on the redeemer output script will be always lower than this value
|
|
401
410
|
/// since the treasury and Bitcoin transaction fees must be incurred.
|
|
@@ -423,11 +432,81 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
423
432
|
self.requestRedemption(
|
|
424
433
|
walletPubKeyHash,
|
|
425
434
|
mainUtxo,
|
|
435
|
+
msg.sender,
|
|
426
436
|
redeemerOutputScript,
|
|
427
437
|
amount
|
|
428
438
|
);
|
|
429
439
|
}
|
|
430
440
|
|
|
441
|
+
/// @notice Requests redemption of the given amount from the specified
|
|
442
|
+
/// wallet to the redeemer Bitcoin output script. Used by
|
|
443
|
+
/// `Bank.approveBalanceAndCall`. Can handle more complex cases
|
|
444
|
+
/// where balance owner may be someone else than the redeemer.
|
|
445
|
+
/// For example, vault redeeming its balance for some depositor.
|
|
446
|
+
/// @param balanceOwner The address of the Bank balance owner whose balance
|
|
447
|
+
/// is getting redeemed.
|
|
448
|
+
/// @param amount Requested amount in satoshi. This is also the Bank balance
|
|
449
|
+
/// that is taken from the `balanceOwner` upon request.
|
|
450
|
+
/// Once the request is handled, the actual amount of BTC locked
|
|
451
|
+
/// on the redeemer output script will be always lower than this value
|
|
452
|
+
/// since the treasury and Bitcoin transaction fees must be incurred.
|
|
453
|
+
/// The minimal amount satisfying the request can be computed as:
|
|
454
|
+
/// `amount - (amount / redemptionTreasuryFeeDivisor) - redemptionTxMaxFee`.
|
|
455
|
+
/// Fees values are taken at the moment of request creation.
|
|
456
|
+
/// @param redemptionData ABI-encoded redemption data:
|
|
457
|
+
/// [
|
|
458
|
+
/// address redeemer,
|
|
459
|
+
/// bytes20 walletPubKeyHash,
|
|
460
|
+
/// bytes32 mainUtxoTxHash,
|
|
461
|
+
/// uint32 mainUtxoTxOutputIndex,
|
|
462
|
+
/// uint64 mainUtxoTxOutputValue,
|
|
463
|
+
/// bytes redeemerOutputScript
|
|
464
|
+
/// ]
|
|
465
|
+
///
|
|
466
|
+
/// - redeemer: The Ethereum address of the redeemer who will be able
|
|
467
|
+
/// to claim Bank balance if anything goes wrong during the redemption.
|
|
468
|
+
/// In the most basic case, when someone redeems their balance
|
|
469
|
+
/// from the Bank, `balanceOwner` is the same as `redemeer`.
|
|
470
|
+
/// However, when a Vault is redeeming part of its balance for some
|
|
471
|
+
/// redeemer address (for example, someone who has earlier deposited
|
|
472
|
+
/// into that Vault), `balanceOwner` is the Vault, and `redemeer` is
|
|
473
|
+
/// the address for which the vault is redeeming its balance to,
|
|
474
|
+
/// - walletPubKeyHash: The 20-byte wallet public key hash (computed
|
|
475
|
+
/// using Bitcoin HASH160 over the compressed ECDSA public key),
|
|
476
|
+
/// - mainUtxoTxHash: Data of the wallet's main UTXO TX hash, as
|
|
477
|
+
/// currently known on the Ethereum chain,
|
|
478
|
+
/// - mainUtxoTxOutputIndex: Data of the wallet's main UTXO output
|
|
479
|
+
/// index, as currently known on Ethereum chain,
|
|
480
|
+
/// - mainUtxoTxOutputValue: Data of the wallet's main UTXO output
|
|
481
|
+
/// value, as currently known on Ethereum chain,
|
|
482
|
+
/// - redeemerOutputScript The redeemer's length-prefixed output
|
|
483
|
+
/// script (P2PKH, P2WPKH, P2SH or P2WSH) that will be used to lock
|
|
484
|
+
/// redeemed BTC.
|
|
485
|
+
/// @dev Requirements:
|
|
486
|
+
/// - The caller must be the Bank,
|
|
487
|
+
/// - Wallet behind `walletPubKeyHash` must be live,
|
|
488
|
+
/// - `mainUtxo` components must point to the recent main UTXO
|
|
489
|
+
/// of the given wallet, as currently known on the Ethereum chain,
|
|
490
|
+
/// - `redeemerOutputScript` must be a proper Bitcoin script,
|
|
491
|
+
/// - `redeemerOutputScript` cannot have wallet PKH as payload,
|
|
492
|
+
/// - `amount` must be above or equal the `redemptionDustThreshold`,
|
|
493
|
+
/// - Given `walletPubKeyHash` and `redeemerOutputScript` pair can be
|
|
494
|
+
/// used for only one pending request at the same time,
|
|
495
|
+
/// - Wallet must have enough Bitcoin balance to proceed the request,
|
|
496
|
+
function receiveBalanceApproval(
|
|
497
|
+
address balanceOwner,
|
|
498
|
+
uint256 amount,
|
|
499
|
+
bytes calldata redemptionData
|
|
500
|
+
) external override {
|
|
501
|
+
require(msg.sender == address(self.bank), "Caller is not the bank");
|
|
502
|
+
|
|
503
|
+
self.requestRedemption(
|
|
504
|
+
balanceOwner,
|
|
505
|
+
SafeCastUpgradeable.toUint64(amount),
|
|
506
|
+
redemptionData
|
|
507
|
+
);
|
|
508
|
+
}
|
|
509
|
+
|
|
431
510
|
/// @notice Used by the wallet to prove the BTC redemption transaction
|
|
432
511
|
/// and to make the necessary bookkeeping. Redemption is only
|
|
433
512
|
/// accepted if it satisfies SPV proof.
|
|
@@ -1115,7 +1194,7 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
1115
1194
|
/// It is the time after which the redemption request can be reported
|
|
1116
1195
|
/// as timed out. It is counted from the moment when the redemption
|
|
1117
1196
|
/// request was created via `requestRedemption` call. Reported timed
|
|
1118
|
-
/// out requests are cancelled and locked
|
|
1197
|
+
/// out requests are cancelled and locked balance is returned to the
|
|
1119
1198
|
/// redeemer in full amount.
|
|
1120
1199
|
/// @param redemptionTimeoutSlashingAmount New value of the redemption
|
|
1121
1200
|
/// timeout slashing amount in T, it is the amount slashed from each
|
|
@@ -1502,7 +1581,7 @@ contract Bridge is Governable, EcdsaWalletOwner, Initializable {
|
|
|
1502
1581
|
/// @return redemptionTimeout Time after which the redemption request can be
|
|
1503
1582
|
/// reported as timed out. It is counted from the moment when the
|
|
1504
1583
|
/// redemption request was created via `requestRedemption` call.
|
|
1505
|
-
/// Reported timed out requests are cancelled and locked
|
|
1584
|
+
/// Reported timed out requests are cancelled and locked balance is
|
|
1506
1585
|
/// returned to the redeemer in full amount.
|
|
1507
1586
|
/// @return redemptionTimeoutSlashingAmount The amount of stake slashed
|
|
1508
1587
|
/// from each member of a wallet for a redemption timeout.
|
|
@@ -233,15 +233,21 @@ library Redemption {
|
|
|
233
233
|
|
|
234
234
|
/// @notice Requests redemption of the given amount from the specified
|
|
235
235
|
/// wallet to the redeemer Bitcoin output script.
|
|
236
|
+
/// This function handles the simplest case, where balance owner is
|
|
237
|
+
/// the redeemer.
|
|
236
238
|
/// @param walletPubKeyHash The 20-byte wallet public key hash (computed
|
|
237
239
|
/// using Bitcoin HASH160 over the compressed ECDSA public key).
|
|
238
240
|
/// @param mainUtxo Data of the wallet's main UTXO, as currently known on
|
|
239
241
|
/// the Ethereum chain.
|
|
242
|
+
/// @param balanceOwner The address of the Bank balance owner whose balance
|
|
243
|
+
/// is getting redeemed. Balance owner address is stored as
|
|
244
|
+
/// a redemeer address who will be able co claim back the Bank
|
|
245
|
+
/// balance if anything goes wrong during the redemption.
|
|
240
246
|
/// @param redeemerOutputScript The redeemer's length-prefixed output
|
|
241
247
|
/// script (P2PKH, P2WPKH, P2SH or P2WSH) that will be used to lock
|
|
242
248
|
/// redeemed BTC.
|
|
243
|
-
/// @param amount Requested amount in satoshi. This is also the
|
|
244
|
-
/// that is taken from
|
|
249
|
+
/// @param amount Requested amount in satoshi. This is also the Bank balance
|
|
250
|
+
/// that is taken from the `balanceOwner` upon request.
|
|
245
251
|
/// Once the request is handled, the actual amount of BTC locked
|
|
246
252
|
/// on the redeemer output script will be always lower than this value
|
|
247
253
|
/// since the treasury and Bitcoin transaction fees must be incurred.
|
|
@@ -258,15 +264,163 @@ library Redemption {
|
|
|
258
264
|
/// - Given `walletPubKeyHash` and `redeemerOutputScript` pair can be
|
|
259
265
|
/// used for only one pending request at the same time,
|
|
260
266
|
/// - Wallet must have enough Bitcoin balance to proceed the request,
|
|
261
|
-
/// -
|
|
267
|
+
/// - Balance owner must make an allowance in the Bank that the Bridge
|
|
262
268
|
/// contract can spend the given `amount`.
|
|
263
269
|
function requestRedemption(
|
|
264
270
|
BridgeState.Storage storage self,
|
|
265
271
|
bytes20 walletPubKeyHash,
|
|
266
272
|
BitcoinTx.UTXO calldata mainUtxo,
|
|
273
|
+
address balanceOwner,
|
|
267
274
|
bytes calldata redeemerOutputScript,
|
|
268
275
|
uint64 amount
|
|
269
276
|
) external {
|
|
277
|
+
requestRedemption(
|
|
278
|
+
self,
|
|
279
|
+
walletPubKeyHash,
|
|
280
|
+
mainUtxo,
|
|
281
|
+
balanceOwner,
|
|
282
|
+
balanceOwner,
|
|
283
|
+
redeemerOutputScript,
|
|
284
|
+
amount
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/// @notice Requests redemption of the given amount from the specified
|
|
289
|
+
/// wallet to the redeemer Bitcoin output script. Used by
|
|
290
|
+
/// `Bridge.receiveBalanceApproval`. Can handle more complex cases
|
|
291
|
+
/// where balance owner may be someone else than the redeemer.
|
|
292
|
+
/// @param balanceOwner The address of the Bank balance owner whose balance
|
|
293
|
+
/// is getting redeemed.
|
|
294
|
+
/// @param amount Requested amount in satoshi. This is also the Bank balance
|
|
295
|
+
/// that is taken from the `balanceOwner` upon request.
|
|
296
|
+
/// Once the request is handled, the actual amount of BTC locked
|
|
297
|
+
/// on the redeemer output script will be always lower than this value
|
|
298
|
+
/// since the treasury and Bitcoin transaction fees must be incurred.
|
|
299
|
+
/// The minimal amount satisfying the request can be computed as:
|
|
300
|
+
/// `amount - (amount / redemptionTreasuryFeeDivisor) - redemptionTxMaxFee`.
|
|
301
|
+
/// Fees values are taken at the moment of request creation.
|
|
302
|
+
/// @param redemptionData ABI-encoded redemption data:
|
|
303
|
+
/// [
|
|
304
|
+
/// address redeemer,
|
|
305
|
+
/// bytes20 walletPubKeyHash,
|
|
306
|
+
/// bytes32 mainUtxoTxHash,
|
|
307
|
+
/// uint32 mainUtxoTxOutputIndex,
|
|
308
|
+
/// uint64 mainUtxoTxOutputValue,
|
|
309
|
+
/// bytes redeemerOutputScript
|
|
310
|
+
/// ]
|
|
311
|
+
///
|
|
312
|
+
/// - redeemer: The Ethereum address of the redeemer who will be able
|
|
313
|
+
/// to claim Bank balance if anything goes wrong during the redemption.
|
|
314
|
+
/// In the most basic case, when someone redeems their Bitcoin
|
|
315
|
+
/// balance from the Bank, `balanceOwner` is the same as `redemeer`.
|
|
316
|
+
/// However, when a Vault is redeeming part of its balance for some
|
|
317
|
+
/// redeemer address (for example, someone who has earlier deposited
|
|
318
|
+
/// into that Vault), `balanceOwner` is the Vault, and `redemeer` is
|
|
319
|
+
/// the address for which the vault is redeeming its balance to,
|
|
320
|
+
/// - walletPubKeyHash: The 20-byte wallet public key hash (computed
|
|
321
|
+
/// using Bitcoin HASH160 over the compressed ECDSA public key),
|
|
322
|
+
/// - mainUtxoTxHash: Data of the wallet's main UTXO TX hash, as
|
|
323
|
+
/// currently known on the Ethereum chain,
|
|
324
|
+
/// - mainUtxoTxOutputIndex: Data of the wallet's main UTXO output
|
|
325
|
+
/// index, as currently known on Ethereum chain,
|
|
326
|
+
/// - mainUtxoTxOutputValue: Data of the wallet's main UTXO output
|
|
327
|
+
/// value, as currently known on Ethereum chain,
|
|
328
|
+
/// - redeemerOutputScript The redeemer's length-prefixed output
|
|
329
|
+
/// script (P2PKH, P2WPKH, P2SH or P2WSH) that will be used to lock
|
|
330
|
+
/// redeemed BTC.
|
|
331
|
+
/// @dev Requirements:
|
|
332
|
+
/// - Wallet behind `walletPubKeyHash` must be live,
|
|
333
|
+
/// - `mainUtxo*` components must point to the recent main UTXO
|
|
334
|
+
/// of the given wallet, as currently known on the Ethereum chain,
|
|
335
|
+
/// - `redeemerOutputScript` must be a proper Bitcoin script,
|
|
336
|
+
/// - `redeemerOutputScript` cannot have wallet PKH as payload,
|
|
337
|
+
/// - `amount` must be above or equal the `redemptionDustThreshold`,
|
|
338
|
+
/// - Given `walletPubKeyHash` and `redeemerOutputScript` pair can be
|
|
339
|
+
/// used for only one pending request at the same time,
|
|
340
|
+
/// - Wallet must have enough Bitcoin balance to proceed the request,
|
|
341
|
+
/// - Balance owner must make an allowance in the Bank that the Bridge
|
|
342
|
+
/// contract can spend the given `amount`.
|
|
343
|
+
function requestRedemption(
|
|
344
|
+
BridgeState.Storage storage self,
|
|
345
|
+
address balanceOwner,
|
|
346
|
+
uint64 amount,
|
|
347
|
+
bytes calldata redemptionData
|
|
348
|
+
) external {
|
|
349
|
+
(
|
|
350
|
+
address redeemer,
|
|
351
|
+
bytes20 walletPubKeyHash,
|
|
352
|
+
bytes32 mainUtxoTxHash,
|
|
353
|
+
uint32 mainUtxoTxOutputIndex,
|
|
354
|
+
uint64 mainUtxoTxOutputValue,
|
|
355
|
+
bytes memory redeemerOutputScript
|
|
356
|
+
) = abi.decode(
|
|
357
|
+
redemptionData,
|
|
358
|
+
(address, bytes20, bytes32, uint32, uint64, bytes)
|
|
359
|
+
);
|
|
360
|
+
|
|
361
|
+
requestRedemption(
|
|
362
|
+
self,
|
|
363
|
+
walletPubKeyHash,
|
|
364
|
+
BitcoinTx.UTXO(
|
|
365
|
+
mainUtxoTxHash,
|
|
366
|
+
mainUtxoTxOutputIndex,
|
|
367
|
+
mainUtxoTxOutputValue
|
|
368
|
+
),
|
|
369
|
+
balanceOwner,
|
|
370
|
+
redeemer,
|
|
371
|
+
redeemerOutputScript,
|
|
372
|
+
amount
|
|
373
|
+
);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/// @notice Requests redemption of the given amount from the specified
|
|
377
|
+
/// wallet to the redeemer Bitcoin output script.
|
|
378
|
+
/// @param walletPubKeyHash The 20-byte wallet public key hash (computed
|
|
379
|
+
/// using Bitcoin HASH160 over the compressed ECDSA public key).
|
|
380
|
+
/// @param mainUtxo Data of the wallet's main UTXO, as currently known on
|
|
381
|
+
/// the Ethereum chain.
|
|
382
|
+
/// @param balanceOwner The address of the Bank balance owner whose balance
|
|
383
|
+
/// is getting redeemed.
|
|
384
|
+
/// @param redeemer The Ethereum address of the redeemer who will be able to
|
|
385
|
+
/// claim Bank balance if anything goes wrong during the redemption.
|
|
386
|
+
/// In the most basic case, when someone redeems their Bitcoin
|
|
387
|
+
/// balance from the Bank, `balanceOwner` is the same as `redemeer`.
|
|
388
|
+
/// However, when a Vault is redeeming part of its balance for some
|
|
389
|
+
/// redeemer address (for example, someone who has earlier deposited
|
|
390
|
+
/// into that Vault), `balanceOwner` is the Vault, and `redemeer` is
|
|
391
|
+
/// the address for which the vault is redeeming its balance to.
|
|
392
|
+
/// @param redeemerOutputScript The redeemer's length-prefixed output
|
|
393
|
+
/// script (P2PKH, P2WPKH, P2SH or P2WSH) that will be used to lock
|
|
394
|
+
/// redeemed BTC.
|
|
395
|
+
/// @param amount Requested amount in satoshi. This is also the Bank balance
|
|
396
|
+
/// that is taken from the `balanceOwner` upon request.
|
|
397
|
+
/// Once the request is handled, the actual amount of BTC locked
|
|
398
|
+
/// on the redeemer output script will be always lower than this value
|
|
399
|
+
/// since the treasury and Bitcoin transaction fees must be incurred.
|
|
400
|
+
/// The minimal amount satisfying the request can be computed as:
|
|
401
|
+
/// `amount - (amount / redemptionTreasuryFeeDivisor) - redemptionTxMaxFee`.
|
|
402
|
+
/// Fees values are taken at the moment of request creation.
|
|
403
|
+
/// @dev Requirements:
|
|
404
|
+
/// - Wallet behind `walletPubKeyHash` must be live,
|
|
405
|
+
/// - `mainUtxo` components must point to the recent main UTXO
|
|
406
|
+
/// of the given wallet, as currently known on the Ethereum chain,
|
|
407
|
+
/// - `redeemerOutputScript` must be a proper Bitcoin script,
|
|
408
|
+
/// - `redeemerOutputScript` cannot have wallet PKH as payload,
|
|
409
|
+
/// - `amount` must be above or equal the `redemptionDustThreshold`,
|
|
410
|
+
/// - Given `walletPubKeyHash` and `redeemerOutputScript` pair can be
|
|
411
|
+
/// used for only one pending request at the same time,
|
|
412
|
+
/// - Wallet must have enough Bitcoin balance to proceed the request,
|
|
413
|
+
/// - Balance owner must make an allowance in the Bank that the Bridge
|
|
414
|
+
/// contract can spend the given `amount`.
|
|
415
|
+
function requestRedemption(
|
|
416
|
+
BridgeState.Storage storage self,
|
|
417
|
+
bytes20 walletPubKeyHash,
|
|
418
|
+
BitcoinTx.UTXO memory mainUtxo,
|
|
419
|
+
address balanceOwner,
|
|
420
|
+
address redeemer,
|
|
421
|
+
bytes memory redeemerOutputScript,
|
|
422
|
+
uint64 amount
|
|
423
|
+
) internal {
|
|
270
424
|
Wallets.Wallet storage wallet = self.registeredWallets[
|
|
271
425
|
walletPubKeyHash
|
|
272
426
|
];
|
|
@@ -358,7 +512,7 @@ library Redemption {
|
|
|
358
512
|
);
|
|
359
513
|
|
|
360
514
|
self.pendingRedemptions[redemptionKey] = RedemptionRequest(
|
|
361
|
-
|
|
515
|
+
redeemer,
|
|
362
516
|
amount,
|
|
363
517
|
treasuryFee,
|
|
364
518
|
txMaxFee,
|
|
@@ -369,13 +523,13 @@ library Redemption {
|
|
|
369
523
|
emit RedemptionRequested(
|
|
370
524
|
walletPubKeyHash,
|
|
371
525
|
redeemerOutputScript,
|
|
372
|
-
|
|
526
|
+
redeemer,
|
|
373
527
|
amount,
|
|
374
528
|
treasuryFee,
|
|
375
529
|
txMaxFee
|
|
376
530
|
);
|
|
377
531
|
|
|
378
|
-
self.bank.transferBalanceFrom(
|
|
532
|
+
self.bank.transferBalanceFrom(balanceOwner, address(this), amount);
|
|
379
533
|
}
|
|
380
534
|
|
|
381
535
|
/// @notice Used by the wallet to prove the BTC redemption transaction
|