forked from omnilaboratory/obd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
message_rsmc.go
163 lines (145 loc) · 7.99 KB
/
message_rsmc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
package bean
//消息 -100351(alice to obd) Alice发给obd (commitment_tx) 申请转账
type RequestCreateCommitmentTx struct {
ChannelId string `json:"channel_id"` //the global channel id.
Amount float64 `json:"amount"` //amount of the payment
LastTempAddressPrivateKey string `json:"last_temp_address_private_key"`
CurrTempAddressIndex int `json:"curr_temp_address_index"`
CurrTempAddressPubKey string `json:"curr_temp_address_pub_key"`
typeLengthValue
}
// 返回值 -100351的返回值 (obd to alice) obd推给Alice (需要Alice签名的数据)
type NeedAliceSignRsmcDataForC2a struct {
ChannelId string `json:"channel_id"` //the global channel id.
RsmcRawData NeedClientSignTxData `json:"rsmc_raw_data"`
CounterpartyRawData NeedClientSignTxData `json:"counterparty_raw_data"`
}
//消息 -100360(alice to obd) alice发给obd (Alice签名C2a的结果)
type AliceSignedRsmcDataForC2a struct {
ChannelId string `json:"channel_id"`
RsmcSignedHex string `json:"rsmc_signed_hex"`
CounterpartySignedHex string `json:"counterparty_signed_hex"`
typeLengthValue
}
//返回值 -100360(alice to obd) alice发给obd (Alice签名C2a的结果)
type AliceSignedRsmcDataForC2aResult struct {
ChannelId string `json:"channel_id"` //the global channel id.
CommitmentTxHash string `json:"commitment_tx_hash"`
Amount float64 `json:"amount"` //amount of the payment
AmountA float64 `json:"amount_a"` //amount of the payment
AmountB float64 `json:"amount_b"` //amount of the payment
CurrTempAddressPubKey string `json:"curr_temp_address_pub_key"`
}
// 消息 p2p 351 p2p (obd of alice to obd of bob) 发送给bob的obd的数据 alice请求rsmc转账
type AliceRequestToCreateCommitmentTxOfP2p struct {
AliceSignedRsmcDataForC2aResult
LastTempAddressPrivateKey string `json:"last_temp_address_private_key"`
RsmcRawData NeedClientSignTxData `json:"rsmc_raw_data"`
CounterpartyRawData NeedClientSignTxData `json:"counterparty_raw_data"`
PayerNodeAddress string `json:"payer_node_address"`
PayerPeerId string `json:"payer_peer_id"`
typeLengthValue
}
// 返回值 -110351 (obd to bob) obd推给bob bob所在的obd发送给bob的需要bob签名的数据:C2a的rsmc和toB
type PayerRequestCommitmentTxToBobClient struct {
AliceRequestToCreateCommitmentTxOfP2p
MsgHash string `json:"msg_hash"`
}
// p2p消息 -100352 (bob to obd) (commitment_tx_signed) bob完成对C2a rsmc和toB的签名,并对这次rsmc转账签收
type PayeeSendSignCommitmentTx struct {
ChannelId string `json:"channel_id"`
MsgHash string `json:"msg_hash"`
C2aRsmcSignedHex string `json:"c2a_rsmc_signed_hex"`
C2aCounterpartySignedHex string `json:"c2a_counterparty_signed_hex"`
LastTempAddressPrivateKey string `json:"last_temp_address_private_key"` // bob2's private key
CurrTempAddressIndex int `json:"curr_temp_address_index"`
CurrTempAddressPubKey string `json:"curr_temp_address_pub_key"` // bob3 or alice3
Approval bool `json:"approval"` // true agree false disagree
typeLengthValue
}
// 返回值 -100352 (obd to bob) 推送给bob,需要bob对C2b的交易进行签名
type NeedBobSignRawDataForC2b struct {
ChannelId string `json:"channel_id"` //the global channel id.
C2bRsmcRawData NeedClientSignTxData `json:"c2b_rsmc_raw_data"`
C2bCounterpartyRawData NeedClientSignTxData `json:"c2b_counterparty_raw_data"`
C2aRdRawData NeedClientSignTxData `json:"c2a_rd_raw_data"`
C2aBrRawData NeedClientSignRawBRTxData `json:"c2a_br_raw_data"`
}
// 消息 100361 (bob to obd) bob对C2b的签名结果
type BobSignedRsmcDataForC2b struct {
ChannelId string `json:"channel_id"` //the global channel id.
C2bRsmcSignedHex string `json:"c2b_rsmc_signed_hex"`
C2bCounterpartySignedHex string `json:"c2b_counterparty_signed_hex"`
C2aRdSignedHex string `json:"c2a_rd_signed_hex"`
C2aBrSignedHex string `json:"c2a_br_signed_hex"`
C2aBrId int64 `json:"c2a_br_id"`
typeLengthValue
}
// 消息 100361 (bob to obd) bob对C2b的签名结果
type BobSignedRsmcDataForC2bResult struct {
ChannelId string `json:"channel_id"` //the global channel id.
CommitmentTxHash string `json:"commitment_tx_hash"`
Approval bool `json:"approval"`
}
//p2p消息 -100361 -> 352 (obd of bob to obd of alice) bob的obd把c2b的相关信息通过p2p推送过alice的obd
type PayeeSignCommitmentTxOfP2p struct {
BobSignedRsmcDataForC2bResult
C2bRsmcTxData NeedClientSignTxData `json:"c2b_rsmc_tx_data"`
C2bCounterpartyTxData NeedClientSignTxData `json:"c2b_counterparty_tx_data"`
LastTempAddressPrivateKey string `json:"last_temp_address_private_key"`
CurrTempAddressPubKey string `json:"curr_temp_address_pub_key"`
C2aSignedRsmcHex string `json:"c2a_signed_rsmc_hex"`
C2aSignedToCounterpartyTxHex string `json:"c2a_signed_to_counterparty_tx_hex"`
C2aRdTxData NeedClientSignTxData `json:"c2a_rd_tx_data"`
typeLengthValue
}
// 返回值 110352(obd to Alice)352给Alice的返回值 obd推送给alice,为c2b的Rsmc和toBob,以及c2a的Rd签名
type NeedAliceSignRsmcTxForC2b struct {
ChannelId string `json:"channel_id"` //the global channel id.
C2bRsmcPartialData NeedClientSignTxData `json:"c2b_rsmc_partial_data"`
C2bCounterpartyPartialData NeedClientSignTxData `json:"c2b_counterparty_partial_data"`
C2aRdPartialData NeedClientSignTxData `json:"c2a_rd_partial_data"`
PayeeNodeAddress string `json:"payee_node_address"`
PayeePeerId string `json:"payee_peer_id"`
}
// 消息 100362(alice to obd) Alice完成对C2b的相关信息签名
type AliceSignedRsmcTxForC2b struct {
ChannelId string `json:"channel_id"` //the global channel id.
C2bRsmcSignedHex string `json:"c2b_rsmc_signed_hex"`
C2bCounterpartySignedHex string `json:"c2b_counterparty_signed_hex"`
C2aRdSignedHex string `json:"c2a_rd_signed_hex"`
typeLengthValue
}
// 返回值 100362的返回值(obd to Alice) obd推送给alice,为c2b的Rd和BR签名
type NeedAliceSignRdTxForC2b struct {
ChannelId string `json:"channel_id"` //the global channel id.
C2bRdRawData NeedClientSignTxData `json:"c2b_rd_raw_data"`
C2bBrRawData NeedClientSignRawBRTxData `json:"c2b_br_raw_data"`
}
// 消息 100363(alice to obd) Alice完成对C2b的Rd和BR的相关信息签名
type AliceSignedRdTxForC2b struct {
ChannelId string `json:"channel_id"`
C2bRdSignedHex string `json:"c2b_rd_signed_hex"`
C2bBrSignedHex string `json:"c2b_br_signed_hex"`
C2bBrId int64 `json:"c2b_br_id"`
typeLengthValue
}
// p2p 消息 353(obd of alice to obd of bob) Alice完成c2b的Rd和Br的签名,把签名结果发给bob所在的obd
type AliceSignedC2bTxDataP2p struct {
ChannelId string `json:"channel_id"`
C2aCommitmentTxHash string `json:"c2a_commitment_tx_hash"`
C2bRsmcSignedHex string `json:"c2b_rsmc_signed_hex"`
C2bCounterpartySignedHex string `json:"c2b_counterparty_signed_hex"`
C2bRdPartialData NeedClientSignTxData `json:"c2b_rd_partial_data"`
}
// 返回值 110353(obd to bob) 353给bob的返回值 把需要签名的rd交易推给bob
type NeedBobSignRdTxForC2b struct {
ChannelId string `json:"channel_id"`
C2bRdPartialData NeedClientSignTxData `json:"c2b_rd_partial_data"`
}
// 消息 100364(to obd) bob签名rd完成后的结果
type BobSignedRdTxForC2b struct {
ChannelId string `json:"channel_id"`
C2bRdSignedHex string `json:"c2b_rd_signed_hex"`
typeLengthValue
}