Skip to content

Commit f76097c

Browse files
committed
Merge remote-tracking branch origin/master into tree-plus
2 parents 640647b + b5b548f commit f76097c

File tree

28 files changed

+573
-371
lines changed

28 files changed

+573
-371
lines changed

api-spec/openapi/swagger/ark/v1/service.swagger.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,9 @@
885885
"properties": {
886886
"signedRedeemTx": {
887887
"type": "string"
888+
},
889+
"txid": {
890+
"type": "string"
888891
}
889892
}
890893
},

api-spec/protobuf/ark/v1/service.proto

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ message SubmitRedeemTxRequest {
185185
}
186186
message SubmitRedeemTxResponse {
187187
string signed_redeem_tx = 1;
188+
string txid = 2;
188189
}
189190

190191
message GetTransactionsStreamRequest {}

api-spec/protobuf/gen/ark/v1/service.pb.go

Lines changed: 146 additions & 137 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/main.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ var (
113113
Name: "amount",
114114
Usage: "amount to send in sats",
115115
}
116+
zeroFeesFlag = &cli.BoolFlag{
117+
Name: "zero-fees",
118+
Aliases: []string{"z"},
119+
Usage: "UNSAFE: allow sending offchain transactions with zero fees, disable unilateral exit",
120+
Value: false,
121+
}
116122
enableExpiryCoinselectFlag = &cli.BoolFlag{
117123
Name: "enable-expiry-coinselect",
118124
Usage: "select VTXOs about to expire first",
@@ -200,7 +206,7 @@ var (
200206
Action: func(ctx *cli.Context) error {
201207
return send(ctx)
202208
},
203-
Flags: []cli.Flag{receiversFlag, toFlag, amountFlag, enableExpiryCoinselectFlag, passwordFlag},
209+
Flags: []cli.Flag{receiversFlag, toFlag, amountFlag, enableExpiryCoinselectFlag, passwordFlag, zeroFeesFlag},
204210
}
205211
redeemCommand = cli.Command{
206212
Name: "redeem",
@@ -327,6 +333,7 @@ func send(ctx *cli.Context) error {
327333
receiversJSON := ctx.String(receiversFlag.Name)
328334
to := ctx.String(toFlag.Name)
329335
amount := ctx.Uint64(amountFlag.Name)
336+
zeroFees := ctx.Bool(zeroFeesFlag.Name)
330337
if receiversJSON == "" && to == "" && amount == 0 {
331338
return fmt.Errorf("missing destination, use --to and --amount or --receivers")
332339
}
@@ -366,7 +373,7 @@ func send(ctx *cli.Context) error {
366373
}
367374

368375
if isBitcoin {
369-
return sendCovenantLess(ctx, receivers)
376+
return sendCovenantLess(ctx, receivers, zeroFees)
370377
}
371378
return sendCovenant(ctx, receivers)
372379
}
@@ -535,7 +542,7 @@ func parseReceivers(receveirsJSON string, isBitcoin bool) ([]arksdk.Receiver, er
535542
return receivers, nil
536543
}
537544

538-
func sendCovenantLess(ctx *cli.Context, receivers []arksdk.Receiver) error {
545+
func sendCovenantLess(ctx *cli.Context, receivers []arksdk.Receiver, withZeroFees bool) error {
539546
var onchainReceivers, offchainReceivers []arksdk.Receiver
540547

541548
for _, receiver := range receivers {
@@ -556,7 +563,7 @@ func sendCovenantLess(ctx *cli.Context, receivers []arksdk.Receiver) error {
556563

557564
computeExpiration := ctx.Bool(enableExpiryCoinselectFlag.Name)
558565
redeemTx, err := arkSdkClient.SendOffChain(
559-
ctx.Context, computeExpiration, offchainReceivers,
566+
ctx.Context, computeExpiration, offchainReceivers, withZeroFees,
560567
)
561568
if err != nil {
562569
return err
@@ -590,7 +597,7 @@ func sendCovenant(ctx *cli.Context, receivers []arksdk.Receiver) error {
590597

591598
computeExpiration := ctx.Bool(enableExpiryCoinselectFlag.Name)
592599
txid, err := arkSdkClient.SendOffChain(
593-
ctx.Context, computeExpiration, offchainReceivers,
600+
ctx.Context, computeExpiration, offchainReceivers, false,
594601
)
595602
if err != nil {
596603
return err

pkg/client-sdk/ark_sdk.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ type ArkClient interface {
2121
SendOnChain(ctx context.Context, receivers []Receiver) (string, error)
2222
SendOffChain(
2323
ctx context.Context, withExpiryCoinselect bool, receivers []Receiver,
24+
withZeroFees bool,
2425
) (string, error)
2526
UnilateralRedeem(ctx context.Context) error
2627
CollaborativeRedeem(

pkg/client-sdk/client/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ type TransportClient interface {
4747
) (<-chan RoundEventChannel, func(), error)
4848
Ping(ctx context.Context, requestID string) error
4949
SubmitRedeemTx(
50-
ctx context.Context, signedRedeemTx string,
51-
) (string, error)
50+
ctx context.Context, partialSignedRedeemTx string,
51+
) (signedRedeemTx, redeemTxid string, err error)
5252
ListVtxos(ctx context.Context, addr string) ([]Vtxo, []Vtxo, error)
5353
GetRound(ctx context.Context, txID string) (*Round, error)
5454
GetRoundByID(ctx context.Context, roundID string) (*Round, error)

pkg/client-sdk/client/grpc/client.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,17 +253,17 @@ func (a *grpcClient) Ping(
253253

254254
func (a *grpcClient) SubmitRedeemTx(
255255
ctx context.Context, redeemTx string,
256-
) (string, error) {
256+
) (string, string, error) {
257257
req := &arkv1.SubmitRedeemTxRequest{
258258
RedeemTx: redeemTx,
259259
}
260260

261261
resp, err := a.svc.SubmitRedeemTx(ctx, req)
262262
if err != nil {
263-
return "", err
263+
return "", "", err
264264
}
265265

266-
return resp.GetSignedRedeemTx(), nil
266+
return resp.GetSignedRedeemTx(), resp.GetTxid(), nil
267267
}
268268

269269
func (a *grpcClient) GetRound(

pkg/client-sdk/client/rest/client.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,17 +383,17 @@ func (a *restClient) Ping(
383383

384384
func (a *restClient) SubmitRedeemTx(
385385
ctx context.Context, redeemTx string,
386-
) (string, error) {
386+
) (string, string, error) {
387387
req := &models.V1SubmitRedeemTxRequest{
388388
RedeemTx: redeemTx,
389389
}
390390
resp, err := a.svc.ArkServiceSubmitRedeemTx(
391391
ark_service.NewArkServiceSubmitRedeemTxParams().WithBody(req),
392392
)
393393
if err != nil {
394-
return "", err
394+
return "", "", err
395395
}
396-
return resp.Payload.SignedRedeemTx, nil
396+
return resp.Payload.SignedRedeemTx, resp.Payload.Txid, nil
397397
}
398398

399399
func (a *restClient) GetRound(

pkg/client-sdk/client/rest/service/models/v1_submit_redeem_tx_response.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/client-sdk/client_test.go

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ type vtxo struct {
5757
Swept bool `json:"swept"`
5858
RedeemTx string `json:"redeemTx"`
5959
CreatedAt string `json:"createdAt"`
60-
IsOOR bool `json:"isOor"`
60+
IsPending bool `json:"isPending"`
6161
}
6262

6363
type vtxos []vtxo
@@ -76,19 +76,20 @@ func (v vtxos) parse() []client.Vtxo {
7676
CreatedAt: parseTimestamp(vv.CreatedAt),
7777
RedeemTx: vv.RedeemTx,
7878
SpentBy: vv.SpentBy,
79-
IsPending: vv.IsOOR,
79+
IsPending: vv.IsPending,
8080
})
8181
}
8282
return list
8383
}
8484

8585
type tx struct {
86-
RoundTxid string `json:"roundTxid"`
87-
RedeemTxid string `json:"redeemTxid"`
88-
Amount string `json:"amount"`
89-
Type string `json:"type"`
90-
Settled bool `json:"settled"`
91-
CreatedAt string `json:"createdAt"`
86+
BoardingTxid string `json:"boardingTxid"`
87+
RoundTxid string `json:"roundTxid"`
88+
RedeemTxid string `json:"redeemTxid"`
89+
Amount string `json:"amount"`
90+
Type string `json:"type"`
91+
Settled bool `json:"settled"`
92+
CreatedAt string `json:"createdAt"`
9293
}
9394

9495
type txs []tx
@@ -98,8 +99,9 @@ func (t txs) parse() []sdktypes.Transaction {
9899
for _, tx := range t {
99100
list = append(list, sdktypes.Transaction{
100101
TransactionKey: sdktypes.TransactionKey{
101-
RedeemTxid: tx.RedeemTxid,
102-
RoundTxid: tx.RoundTxid,
102+
BoardingTxid: tx.BoardingTxid,
103+
RedeemTxid: tx.RedeemTxid,
104+
RoundTxid: tx.RoundTxid,
103105
},
104106
Amount: parseAmount(tx.Amount),
105107
Type: sdktypes.TxType(tx.Type),

pkg/client-sdk/covenant_client.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ func (a *covenantArkClient) SendOnChain(
420420
func (a *covenantArkClient) SendOffChain(
421421
ctx context.Context,
422422
withExpiryCoinselect bool, receivers []Receiver,
423+
_ bool,
423424
) (string, error) {
424425
for _, receiver := range receivers {
425426
if receiver.IsOnchain() {

0 commit comments

Comments
 (0)