forked from hacash/core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pay.go
46 lines (40 loc) · 1 KB
/
pay.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
package channel
import (
"bytes"
)
/**
* 通道支付完整单据
*/
// Channel chain payment bill
type ChannelPayCompleteDocuments struct {
// Reconciliation bill table
ProveBodys *ChannelPayProveBodyList
// Payment of signed bills
ChainPayment *OffChainFormPaymentChannelTransfer
}
func (c ChannelPayCompleteDocuments) Size() uint32 {
return c.ProveBodys.Size() + c.ChainPayment.Size()
}
func (c ChannelPayCompleteDocuments) Serialize() ([]byte, error) {
var buffer bytes.Buffer
var bt1, _ = c.ProveBodys.Serialize()
buffer.Write(bt1)
var bt2, _ = c.ChainPayment.Serialize()
buffer.Write(bt2)
return buffer.Bytes(), nil
}
func (c *ChannelPayCompleteDocuments) Parse(buf []byte, seek uint32) (uint32, error) {
var e error
// passageway
c.ProveBodys = &ChannelPayProveBodyList{}
seek, e = c.ProveBodys.Parse(buf, seek)
if e != nil {
return 0, e
}
c.ChainPayment = &OffChainFormPaymentChannelTransfer{}
seek, e = c.ChainPayment.Parse(buf, seek)
if e != nil {
return 0, e
}
return seek, nil
}