Skip to content

Commit

Permalink
Merge pull request #211 from SiaFoundation/nate/construct-txns
Browse files Browse the repository at this point in the history
Construct Transaction API
  • Loading branch information
n8maninger authored Jan 13, 2025
2 parents dc3c5ab + 86f4307 commit 780c780
Show file tree
Hide file tree
Showing 7 changed files with 1,118 additions and 28 deletions.
9 changes: 9 additions & 0 deletions .changeset/add_transaction_construction_api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
default: minor
---

# Add transaction construction API

Adds two new endpoints to construct transactions. This combines and simplifies the existing fund flow for simple send transactions.

See API docs for request and response bodies
31 changes: 31 additions & 0 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ type GatewayPeer struct {

// TxpoolBroadcastRequest is the request type for /txpool/broadcast.
type TxpoolBroadcastRequest struct {
Basis types.ChainIndex `json:"basis"`
Transactions []types.Transaction `json:"transactions"`
V2Transactions []types.V2Transaction `json:"v2transactions"`
}

// TxpoolTransactionsResponse is the response type for /txpool/transactions.
type TxpoolTransactionsResponse struct {
Basis types.ChainIndex `json:"basis"`
Transactions []types.Transaction `json:"transactions"`
V2Transactions []types.V2Transaction `json:"v2transactions"`
}
Expand Down Expand Up @@ -88,6 +90,35 @@ type WalletFundResponse struct {
DependsOn []types.Transaction `json:"dependsOn"`
}

// WalletConstructRequest is the request type for /wallets/:id/construct.
type WalletConstructRequest struct {
Siacoins []types.SiacoinOutput `json:"siacoins"`
Siafunds []types.SiafundOutput `json:"siafunds"`
ChangeAddress types.Address `json:"changeAddress"`
}

// SignaturePayload is a signature that is required to finalize a transaction.
type SignaturePayload struct {
PublicKey types.PublicKey `json:"publicKey"`
SigHash types.Hash256 `json:"sigHash"`
}

// WalletConstructResponse is the response type for /wallets/:id/construct/transaction.
type WalletConstructResponse struct {
Basis types.ChainIndex `json:"basis"`
ID types.TransactionID `json:"id"`
Transaction types.Transaction `json:"transaction"`
EstimatedFee types.Currency `json:"estimatedFee"`
}

// WalletConstructV2Response is the response type for /wallets/:id/construct/v2/transaction.
type WalletConstructV2Response struct {
Basis types.ChainIndex `json:"basis"`
ID types.TransactionID `json:"id"`
Transaction types.V2Transaction `json:"transaction"`
EstimatedFee types.Currency `json:"estimatedFee"`
}

// SeedSignRequest requests that a transaction be signed using the keys derived
// from the given indices.
type SeedSignRequest struct {
Expand Down
Loading

0 comments on commit 780c780

Please sign in to comment.