5.2 IBC-Bitcoin
Contract Interface
1
struct DepositItem {
2
bytes32 txid;
3
uint vout;
4
uint amount;
5
bytes scriptPubKey;
6
address toAddr;
7
address extraToAddr;
8
bool deposited;
9
bytes32 depositPubKeyX;
10
bytes32 depositPubKeyY;
11
}
12
13
struct WithdrawItem {
14
uint wtype; // 0: default, 1: send to cold
15
uint withdrawId;
16
bytes destination;
17
uint amount;
18
}
19
20
struct Utxo {
21
bytes32 txid;
22
uint vout;
23
uint amount;
24
bytes scriptPubKey;
25
bool used;
26
}
27
28
struct WithdrawTx {
29
bytes32 suggestHash;
30
bytes32[] keyHashs;
31
bytes32[] inputHashs;
32
uint outputStart;
33
uint outputSize;
34
uint fee;
35
uint change;
36
}
37
38
struct Destination {
39
address toAddr;
40
address extraToAddr;
41
}
42
43
mapping(bytes32 => DepositItem) public deposits;
44
mapping(uint => WithdrawItem) public withdrawals;
45
mapping(bytes32 => Utxo) public utxos;
46
mapping(uint => WithdrawTx) public suggestions;
47
mapping(uint => WithdrawTx) public selections;
48
mapping(uint => bytes32) public utxoKeys;
49
mapping(bytes32 => mapping(bytes32 => Destination)) public depositDestinations;
50
mapping(bytes32 => bool) public isUsedMappingHash;
51
52
bool public isActivated = true;
53
uint public utxoCount = 0;
54
uint public validUtxoCount = 0;
55
uint public withdrawalCount = 0;
56
uint public withdrewCount = 0;
57
uint public suggestCount = 0;
58
uint public selectionCount = 0;
59
uint public btcBalance = 0;
60
uint public holdingLimit = 0;
61
62
address tokenAddr = 0x0000000000000000000000000000000000000001;
63
bytes coldAddr;
64
bytes public redeemScript;
65
66
event DepositDestinationsMapping(bytes32 btcPubKeyX, bytes32 btcPubKeyY, address toAddr, address extraToAddr);
67
event DepositRelay(bytes32 txid, uint vout, uint amount, bytes scriptPubKey, bytes32 depositPubKeyX, bytes32 depositPubKeyY);
68
event DepositValidated(bytes32 txid, uint vout, uint amount, bytes scriptPubKey, address toAddr, address extraToAddr, bytes32 depositPubKeyX, bytes32 depositPubKeyY);
69
event WithdrawAdded(address balanceAddr, uint wtype, uint withdrawId, address user, uint withdrawIndex, bytes32 tokenSummary, bytes destination, uint amount);
70
event TxSuggestAdded(bytes32 suggestHash, uint suggestIndex, bytes32[] keyHashs, bytes32[] inputHashs, uint outputStart, uint outputSize, uint fee, uint change);
71
event TxSuggestRelay(bytes32 suggestHash, uint suggestIndex, bytes32[] keyHashs, bytes32[] inputHashs, uint outputStart, uint outputSize, uint fee, uint change);
72
event TxSelected(uint selectionIndex, bytes32[] keyHashs, bytes32[] inputHashs, uint outputStart, uint outputSize, uint fee, uint change);
73
event TxSelectedRelay(uint selectionIndex, bytes32[] keyHashs, bytes32[] inputHashs, uint outputStart, uint outputSize, uint fee, uint change);
74
event WithdrawValidated(uint selectionIndex, bytes32[] keyHashs, bytes32[] inputHashs, uint outputStart, uint outputSize, uint fee);
75
event UsableUtxoRelay(bytes32 txid, uint vout, uint amount, bytes scriptPubKey);
76
event UtxoAdded(uint utxoIndex, bytes32 txid, uint vout, uint amount, bytes scriptPubKey, bytes32 keyHash);
77
78
function getSuggestKeyHashs(uint suggestIndex) public view returns(bytes32[] memory)
79
function getSuggestInputHashs(uint suggestIndex) public view returns(bytes32[] memory)
80
function getSelectionKeyHashs(uint selectionIndex) public view returns(bytes32[] memory)
81
function getSelectionInputHashs(uint selectionIndex) public view returns(bytes32[] memory)
82
function bytes32ToAddress(bytes32 data) public pure returns (address)
83
84
function setDepositDestinations(bytes32[] memory btcPubKeyX, bytes32[] memory btcPubKeyY, address[] memory toAddrs, address[] memory extraToAddrs, bytes32[] memory nonces, uint8[] memory v, bytes32[] memory r, bytes32[] memory s) public
85
function relayDepositUtxo(bytes32 txid, uint vout, uint amount, bytes memory scriptPubKey, bytes32 depositPubKeyX, bytes32 depositPubKeyY) public onlyActivated
86
function relayUsableUtxo(bytes32 txid, uint vout, uint amount, bytes memory scriptPubKey) public
87
function validateDepositUtxo(bytes32 depositKeyHash, address validator, uint8 v, bytes32 r, bytes32 s) public onlyActivated
88
function validateUsableUtxo(bytes32 txid, uint vout, uint amount, bytes memory scriptPubKey, address validator, uint8 v, bytes32 r, bytes32 s) public
89
function withdraw(uint withdrawId, address user, bytes32 tokenSummary, bytes memory destination, uint amount, bytes memory comment) public onlyActivated
90
function withdraw(uint withdrawId, address user, address extraUser, bytes32 tokenSummary, bytes memory destination, uint amount, bytes memory comment) public onlyActivated
91
function withdrawColdScript() public onlyActivated
92
function suggestWithdrawTx(bytes32[] memory keyHashs, bytes32[] memory inputHashs, uint outputSize, uint fee, uint change) public
93
function relayTxSuggest(uint suggestIndex) public
94
function validateSuggest(bytes32 suggestHash, uint suggestIndex, address validator, uint8 v, bytes32 r, bytes32 s) public
95
function relayTxSelected(uint selectionIndex) public
96
function validateWithdraw(uint selectionIndex, address validator, uint8[] memory v, bytes32[] memory r, bytes32[] memory s) public
97
Copied!
Copy link