Skip to content

Commit 6bee5ca

Browse files
committed
return txid in Withdraw RPC
1 parent 26666e6 commit 6bee5ca

File tree

6 files changed

+78
-71
lines changed

6 files changed

+78
-71
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@
434434
"v1WithdrawResponse": {
435435
"type": "object",
436436
"properties": {
437-
"txHex": {
437+
"txid": {
438438
"type": "string"
439439
}
440440
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,5 +124,5 @@ message WithdrawRequest {
124124
}
125125

126126
message WithdrawResponse {
127-
string tx_hex = 1;
127+
string txid = 1;
128128
}

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

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

server/cmd/arkd/commands.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,13 +263,13 @@ func walletWithdrawAction(ctx *cli.Context) error {
263263
url := fmt.Sprintf("%s/v1/admin/withdraw", baseURL)
264264
body := fmt.Sprintf(`{"address": "%s", "amount": %d}`, address, amount)
265265

266-
txHex, err := post[string](url, body, "txHex", macaroon, tlsCertPath)
266+
txid, err := post[string](url, body, "txid", macaroon, tlsCertPath)
267267
if err != nil {
268268
return err
269269
}
270270

271271
fmt.Println("transaction successfully broadcasted:")
272-
fmt.Println(txHex)
272+
fmt.Println(txid)
273273
return nil
274274
}
275275

server/internal/infrastructure/wallet/btc-embedded/wallet.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1221,7 +1221,9 @@ func (s *service) Withdraw(ctx context.Context, address string, amount uint64) (
12211221
return "", err
12221222
}
12231223

1224-
return hex.EncodeToString(buf.Bytes()), nil
1224+
txid := tx.TxHash().String()
1225+
1226+
return txid, nil
12251227
}
12261228

12271229
func (s *service) castNotification(tx *wtxmgr.TxRecord) map[string][]ports.VtxoWithValue {

server/internal/infrastructure/wallet/liquid-standalone/transaction.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
1919
"github.com/vulpemventures/go-elements/elementsutil"
2020
"github.com/vulpemventures/go-elements/psetv2"
21+
"github.com/vulpemventures/go-elements/transaction"
2122
)
2223

2324
const (
@@ -285,7 +286,12 @@ func (s *service) Withdraw(ctx context.Context, address string, amount uint64) (
285286
return "", err
286287
}
287288

288-
return res.GetTxHex(), nil
289+
tx, err := transaction.NewTxFromHex(res.GetTxHex())
290+
if err != nil {
291+
return "", err
292+
}
293+
294+
return tx.TxHash().String(), nil
289295
}
290296

291297
var minRate = chainfee.SatPerKVByte(0.2 * 1000)

0 commit comments

Comments
 (0)