Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Construct Transaction API #211

Merged
merged 8 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .changeset/add_transaction_construction_api.md
n8maninger marked this conversation as resolved.
Show resolved Hide resolved
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
Loading