api: separate method for paych funding

This commit is contained in:
Łukasz Magiera
2022-02-14 19:56:02 +01:00
parent 10af768c60
commit f61eb23f8f
13 changed files with 98 additions and 25 deletions
+14 -5
View File
@@ -23,7 +23,19 @@ type PaychAPI struct {
}
func (a *PaychAPI) PaychGet(ctx context.Context, from, to address.Address, amt types.BigInt, opts api.PaychGetOpts) (*api.ChannelInfo, error) {
ch, mcid, err := a.PaychMgr.GetPaych(ctx, from, to, amt, opts)
ch, mcid, err := a.PaychMgr.GetPaych(ctx, from, to, amt, true, opts)
if err != nil {
return nil, err
}
return &api.ChannelInfo{
Channel: ch,
WaitSentinel: mcid,
}, nil
}
func (a *PaychAPI) PaychFund(ctx context.Context, from, to address.Address, amt types.BigInt) (*api.ChannelInfo, error) {
ch, mcid, err := a.PaychMgr.GetPaych(ctx, from, to, amt, false, api.PaychGetOpts{OffChain: false})
if err != nil {
return nil, err
}
@@ -55,10 +67,7 @@ func (a *PaychAPI) PaychNewPayment(ctx context.Context, from, to address.Address
// TODO: Fix free fund tracking in PaychGet
// TODO: validate voucher spec before locking funds
ch, err := a.PaychGet(ctx, from, to, amount, api.PaychGetOpts{
Reserve: true,
OffChain: false,
})
ch, err := a.PaychGet(ctx, from, to, amount, api.PaychGetOpts{OffChain: false})
if err != nil {
return nil, err
}