OSDN Git Service

init push for pay-to-script-hash (#235)
[bytom/bytom.git] / blockchain / receivers.go
1 package blockchain
2
3 import (
4         "context"
5         "time"
6 )
7
8 // POST /create-account-receiver
9 func (bcr *BlockchainReactor) createAccountReceiver(ctx context.Context, ins struct {
10         AccountInfo string    `json:"account_info"`
11         ExpiresAt   time.Time `json:"expires_at,omitempty"`
12 }) Response {
13         receiver, err := bcr.accounts.CreateReceiver(nil, ins.AccountInfo, ins.ExpiresAt)
14         if err != nil {
15                 return resWrapper(nil, err)
16         }
17
18         return resWrapper(*receiver)
19 }
20
21 func (bcr *BlockchainReactor) createAccountAddress(ctx context.Context, ins struct {
22         AccountInfo string    `json:"account_info"`
23         ExpiresAt   time.Time `json:"expires_at"`
24 }) Response {
25         receiver, err := bcr.accounts.CreateAddressReceiver(ctx, ins.AccountInfo, ins.ExpiresAt)
26         if err != nil {
27                 return resWrapper(nil, err)
28         }
29         return resWrapper(receiver)
30 }