Skip to content

Commit

Permalink
Merge pull request #224 from SiaFoundation/nate/add-basis-to-wallet-fund
Browse files Browse the repository at this point in the history
Add basis to fund responses
  • Loading branch information
lukechampine authored Feb 4, 2025
2 parents ec19b46 + 9969605 commit 6ba9fc5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/add_basis_to_wallet_fund_endpoints.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
default: minor
---

# Add basis to wallet fund endpoints
1 change: 1 addition & 0 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ type WalletFundSFRequest struct {

// WalletFundResponse is the response type for /wallets/:id/fund.
type WalletFundResponse struct {
Basis types.ChainIndex `json:"basis"`
Transaction types.Transaction `json:"transaction"`
ToSign []types.Hash256 `json:"toSign"`
DependsOn []types.Transaction `json:"dependsOn"`
Expand Down
6 changes: 4 additions & 2 deletions api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ func (s *server) walletsFundHandler(jc jape.Context) {
if jc.DecodeParam("id", &id) != nil || jc.Decode(&wfr) != nil {
return
}
utxos, _, change, err := s.wm.SelectSiacoinElements(id, wfr.Amount, false)
utxos, basis, change, err := s.wm.SelectSiacoinElements(id, wfr.Amount, false)
if jc.Check("couldn't get utxos to fund transaction", err) != nil {
return
}
Expand Down Expand Up @@ -652,6 +652,7 @@ func (s *server) walletsFundHandler(jc jape.Context) {
}

jc.Encode(WalletFundResponse{
Basis: basis,
Transaction: txn,
ToSign: toSign,
DependsOn: s.cm.UnconfirmedParents(txn),
Expand All @@ -664,7 +665,7 @@ func (s *server) walletsFundSFHandler(jc jape.Context) {
if jc.DecodeParam("id", &id) != nil || jc.Decode(&wfr) != nil {
return
}
utxos, _, change, err := s.wm.SelectSiafundElements(id, wfr.Amount)
utxos, basis, change, err := s.wm.SelectSiafundElements(id, wfr.Amount)
if jc.Check("couldn't get utxos to fund transaction", err) != nil {
return
}
Expand Down Expand Up @@ -692,6 +693,7 @@ func (s *server) walletsFundSFHandler(jc jape.Context) {
toSign = append(toSign, types.Hash256(sce.ID))
}
jc.Encode(WalletFundResponse{
Basis: basis,
Transaction: txn,
ToSign: toSign,
DependsOn: s.cm.UnconfirmedParents(txn),
Expand Down

0 comments on commit 6ba9fc5

Please sign in to comment.