Skip to content
Draft
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
21 changes: 21 additions & 0 deletions cmd/wavecli/waveclicommands/devrpc/registry_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions docs/daemon_cli_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,27 @@ wavecli dev daemon SyncAssetReceives
wavecli dev daemon ListAssetReceives
```

### `dev daemon EstimateAssetSend` / `SendAsset` / `ListAssetSends`

Pay a version 2 Taproot Asset address from the daemon's asset wallet. The units
can come from every issuance of the asset. The daemon wallet pays the miner fee
of the anchor transaction and the satoshis that the recipient's anchor output
holds.

`EstimateAssetSend` reports both before anything is sent. When the daemon
wallet holds too little, it reports the shortfall instead, with a daemon wallet
address to fund. `SendAsset` pays the address once per `request_id`: a retry
with the same ID returns the first send, and another amount under it fails.
Once the anchor transaction confirms, the daemon hands the proofs to the proof
courier the address names. `ListAssetSends` lists the sends with the units sent
and the height of the confirming block.

```bash
wavecli dev daemon EstimateAssetSend --address <address> --amount 25
wavecli dev daemon SendAsset --request_id pay-1 --address <address> --amount 25
wavecli dev daemon ListAssetSends
```

### `dev daemon deposit-asset` / `dev daemon list-asset-deposits`

Fund a boarding output holding a Taproot Asset from the asset wallet, and list
Expand Down
13 changes: 12 additions & 1 deletion docs/wavewalletdk_mobile.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ The package is gated behind three build tags — `mobile`, `wavewalletrpc`, and

| Shape | Convention | Verbs |
|-------|-----------|-------|
| RPC verbs | **JSON `[]byte` in / out** (throwing) | `GetInfo`, `GenerateSeed`, `CreateWallet`, `UnlockWallet`, `OpenWalletFromPasskey`, `Balance`, `Deposit`, `Receive`, `PrepareSend`, `SendPrepared`, `List`, `Exit`, `ExitStatus`, `ExitSummary`, `GetExitPlan`, `SweepWallet`, `Status`, `NewAssetFundingAddress`, `ListOwnedAssets`, `NewAssetAddress`, `ListAssetAddresses`, `ListAssetReceives`, `DepositAsset`, `ListAssetDeposits`, `BoardAssetDeposit` |
| RPC verbs | **JSON `[]byte` in / out** (throwing) | `GetInfo`, `GenerateSeed`, `CreateWallet`, `UnlockWallet`, `OpenWalletFromPasskey`, `Balance`, `Deposit`, `Receive`, `PrepareSend`, `SendPrepared`, `List`, `Exit`, `ExitStatus`, `ExitSummary`, `GetExitPlan`, `SweepWallet`, `Status`, `NewAssetFundingAddress`, `ListOwnedAssets`, `NewAssetAddress`, `ListAssetAddresses`, `ListAssetReceives`, `EstimateAssetSend`, `SendAsset`, `ListAssetSends`, `DepositAsset`, `ListAssetDeposits`, `BoardAssetDeposit` |
| Lifecycle JSON | **JSON `[]byte` in / out** (throwing) | `StartExternalSeedWallet` |
| Streaming | **pull handle** `Subscription{ next() []byte; close() }` | `Subscribe` |
| Hot-path scalars | **plain `int64`/`bool`** | `ConfirmedBalanceSat`, `PendingInboundSat`, `WalletReady`, `IsRunning` |
Expand Down Expand Up @@ -241,6 +241,17 @@ returns to the foreground, where no mailbox connection survived. A browser
opens no connection to a courier, so the address verbs are not part of the
WebAssembly host.

`SendAsset` pays a version 2 Taproot Asset address, with units of every
issuance of the asset, and takes a `RequestID`: a retry with the same ID
returns the first send instead of paying again. The wallet's own Bitcoin pays
the miner fee of the anchor transaction and the satoshis of the recipient's
anchor output. `EstimateAssetSend` reports both before the user confirms,
and when the wallet holds too little, reports `FundingShortfallSat` with a
`FundingAddress` to fund instead. `ListAssetSends` returns the sends as
`AssetSend` objects, with a `ConfirmationHeight` of zero until the anchor
transaction confirms. Like the address verbs, these are not part of the
WebAssembly host.

## Building the bindings

Prerequisites:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ require (
github.com/lightninglabs/loop v0.33.0-beta
github.com/lightninglabs/neutrino v0.18.0
github.com/lightninglabs/neutrino/cache v1.1.4
github.com/lightninglabs/tap-sdk v0.3.1-0.20261126165818-f1d8eee682d5
github.com/lightninglabs/tap-sdk v0.3.1-0.20261130125744-ce3254ea448f
github.com/lightninglabs/wavelength/baselib v0.0.0-00010101000000-000000000000
github.com/lightningnetwork/lightning-onion v1.4.0
github.com/lightningnetwork/lnd v0.21.0-beta.rc2.0.20260903094101-d66a7c137d32
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1065,8 +1065,8 @@ github.com/lightninglabs/neutrino/cache v1.1.4 h1:KVtvUmBwYr7eKtjfjHG/q6/cQlcrjH
github.com/lightninglabs/neutrino/cache v1.1.4/go.mod h1:ZqLzxghPggIRfNXeAZN1VtTKofMyK/ALI6niYsPH6OE=
github.com/lightninglabs/protobuf-go-hex-display v1.33.0-hex-display h1:Y2WiPkBS/00EiEg0qp0FhehxnQfk3vv8U6Xt3nN+rTY=
github.com/lightninglabs/protobuf-go-hex-display v1.33.0-hex-display/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
github.com/lightninglabs/tap-sdk v0.3.1-0.20261126165818-f1d8eee682d5 h1:OIJdp5beCupZDqWdIBTBylzjIpTUOirC9vCRoU8aSp0=
github.com/lightninglabs/tap-sdk v0.3.1-0.20261126165818-f1d8eee682d5/go.mod h1:/WmnlztiwXPfH7AEKNKLWp/CdCRfD1h3BZr9verpE4U=
github.com/lightninglabs/tap-sdk v0.3.1-0.20261130125744-ce3254ea448f h1:d3w2w8Q1D3PqfZyj/YKrJgPVydCJiKxGZQ2vZ1mp4/Q=
github.com/lightninglabs/tap-sdk v0.3.1-0.20261130125744-ce3254ea448f/go.mod h1:/WmnlztiwXPfH7AEKNKLWp/CdCRfD1h3BZr9verpE4U=
github.com/lightninglabs/taproot-assets v0.7.1-0.20261124144251-84ab2642333d h1:qS8FlGw3TwLuaDXqc4+YtGKfHcfjs0QXUAv3NcAO39I=
github.com/lightninglabs/taproot-assets v0.7.1-0.20261124144251-84ab2642333d/go.mod h1:HFWeFDaIsxJxsk8N6bUe+ViNIj1xggtDbbBQOZCWfWc=
github.com/lightninglabs/taproot-assets/taprpc v1.1.1-0.20261124144251-84ab2642333d h1:KceJt1a9CcpwHwKbK5fJg38ZQN7LYybiUfWbItQ9MaY=
Expand Down
34 changes: 34 additions & 0 deletions rpc/restclient/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,40 @@ func (c *DaemonServiceClient) SyncAssetReceives(ctx context.Context,
return out, err
}

// EstimateAssetSend reports what paying a Taproot Asset address costs the
// daemon wallet.
func (c *DaemonServiceClient) EstimateAssetSend(ctx context.Context,
in *waverpc.EstimateAssetSendRequest, _ ...grpc.CallOption) (
*waverpc.AssetSendEstimate, error) {

out := new(waverpc.AssetSendEstimate)
err := c.client.Post(ctx, "/v1/daemon/estimate-asset-send", in, out)

return out, err
}

// SendAsset pays a Taproot Asset address from the daemon's asset wallet.
func (c *DaemonServiceClient) SendAsset(ctx context.Context,
in *waverpc.SendAssetRequest, _ ...grpc.CallOption) (*waverpc.AssetSend,
error) {

out := new(waverpc.AssetSend)
err := c.client.Post(ctx, "/v1/daemon/send-asset", in, out)

return out, err
}

// ListAssetSends returns the sends of the daemon's asset wallet.
func (c *DaemonServiceClient) ListAssetSends(ctx context.Context,
in *waverpc.ListAssetSendsRequest, _ ...grpc.CallOption) (
*waverpc.ListAssetSendsResponse, error) {

out := new(waverpc.ListAssetSendsResponse)
err := c.client.Post(ctx, "/v1/daemon/list-asset-sends", in, out)

return out, err
}

// JoinNextRound commits queued round intents and joins the next round.
func (c *DaemonServiceClient) JoinNextRound(ctx context.Context,
in *waverpc.JoinNextRoundRequest, _ ...grpc.CallOption) (
Expand Down
6 changes: 6 additions & 0 deletions sdk/wavewalletdk/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ For field-level detail, use `go doc github.com/lightninglabs/wavelength/sdk/wave
those addresses and `Config.AssetCourierEndpoints` the couriers reached at
another host or with their own TLS certificate; the daemon names no
courier by default, and a browser host receives at no address.
`EstimateAssetSend`, `SendAsset` and `ListAssetSends` pay a Taproot Asset
address (`AssetSendEstimate`, `AssetSend`). `SendAsset` takes a
`RequestID`, and a retry with the same ID returns the first send. The
backing wallet pays for the anchor transaction; an estimate for a wallet
that holds too little reports the shortfall and an address to fund. A
browser host pays no address.
- `ErrWalletRPCUnavailable` — sentinel returned by every wallet method
on builds without the `wavewalletrpc` tag.
- `ErrSwapRuntimeUnavailable` — back-compat alias for
Expand Down
6 changes: 6 additions & 0 deletions sdk/wavewalletdk/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ For field-level detail, use `go doc github.com/lightninglabs/wavelength/sdk/wave
those addresses and `Config.AssetCourierEndpoints` the couriers reached at
another host or with their own TLS certificate; the daemon names no
courier by default, and a browser host receives at no address.
`EstimateAssetSend`, `SendAsset` and `ListAssetSends` pay a Taproot Asset
address (`AssetSendEstimate`, `AssetSend`). `SendAsset` takes a
`RequestID`, and a retry with the same ID returns the first send. The
backing wallet pays for the anchor transaction; an estimate for a wallet
that holds too little reports the shortfall and an address to fund. A
browser host pays no address.
- `ErrWalletRPCUnavailable` — sentinel returned by every wallet method
on builds without the `wavewalletrpc` tag.
- `ErrSwapRuntimeUnavailable` — back-compat alias for
Expand Down
156 changes: 156 additions & 0 deletions sdk/wavewalletdk/assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,89 @@ type AssetReceive struct {
ConfirmationHeight uint32
}

// EstimateAssetSendRequest names a payment to a Taproot Asset address whose
// cost to estimate.
type EstimateAssetSendRequest struct {
// Address is the version 2 Taproot Asset address to pay.
Address string

// Amount is the number of asset units to send. An address that names
// an amount takes zero or that amount.
Amount AssetUnits

// SatPerVByte is the fee rate of the anchor transaction. Zero uses
// the chain backend's estimate for confirmation within 6 blocks.
SatPerVByte uint64
}

// AssetSendEstimate is what paying a Taproot Asset address costs the backing
// wallet: the miner fee of the anchor transaction and the satoshis that the
// recipient's anchor output holds. A backing wallet that holds too little
// reports its shortfall instead, with an address to fund.
type AssetSendEstimate struct {
// SatPerVByte is the fee rate of the anchor transaction, rounded up.
SatPerVByte uint64

// ChainFeeSat is the miner fee of the anchor transaction, zero when
// the backing wallet holds too little.
ChainFeeSat int64

// RecipientAnchorSat is the satoshis that the recipient's anchor
// output holds, zero when the backing wallet holds too little.
RecipientAnchorSat int64

// FundingShortfallSat is how many more satoshis the backing wallet
// needs for the send, zero when it can pay.
FundingShortfallSat int64

// FundingAddress is a backing-wallet address that takes the
// shortfall, empty when there is none.
FundingAddress string
}

// SendAssetRequest pays a Taproot Asset address from the asset wallet.
type SendAssetRequest struct {
// RequestID identifies the send and is required. A retry with the
// same ID returns the first send instead of paying again.
RequestID string

// Address is the version 2 Taproot Asset address to pay.
Address string

// Amount is the number of asset units to send. An address that names
// an amount takes zero or that amount.
Amount AssetUnits

// SatPerVByte is the fee rate of the anchor transaction. Zero uses
// the chain backend's estimate for confirmation within 6 blocks.
SatPerVByte uint64
}

// AssetSend is a payment of the asset wallet to a Taproot Asset address.
type AssetSend struct {
// RequestID is the ID the send was made under.
RequestID string

// AnchorTxid is the ID of the transaction that anchors the send.
AnchorTxid string

// AssetRef is the group key of a grouped asset, else the asset ID.
AssetRef string

// Amount is the number of asset units sent.
Amount AssetUnits

// ChainFeeSat is the miner fee of the anchor transaction.
ChainFeeSat int64

// ConfirmationHeight is the height of the block that confirms the
// anchor transaction, zero while it is unconfirmed.
ConfirmationHeight uint32

// Timestamp is when the wallet recorded the send, in Unix seconds.
Timestamp int64
}

// DepositAssetRequest funds a boarding output holding a Taproot Asset.
type DepositAssetRequest struct {
// RequestID identifies the deposit; a retry with the same ID resumes
Expand Down Expand Up @@ -281,6 +364,66 @@ func (c *Client) SyncAssetReceives(ctx context.Context) error {
return nil
}

// EstimateAssetSend reports what paying a Taproot Asset address costs the
// backing wallet, and sends nothing.
func (c *Client) EstimateAssetSend(ctx context.Context,
req EstimateAssetSendRequest) (*AssetSendEstimate, error) {

resp, err := c.daemon.EstimateAssetSend(
ctx, &waverpc.EstimateAssetSendRequest{
Address: req.Address,
Amount: uint64(req.Amount),
SatPerVbyte: req.SatPerVByte,
},
)
if err != nil {
return nil, fmt.Errorf("estimate asset send: %w", err)
}

return &AssetSendEstimate{
SatPerVByte: resp.GetSatPerVbyte(),
ChainFeeSat: resp.GetChainFeeSat(),
RecipientAnchorSat: resp.GetRecipientAnchorSat(),
FundingShortfallSat: resp.GetFundingShortfallSat(),
FundingAddress: resp.GetFundingAddress(),
}, nil
}

// SendAsset pays a Taproot Asset address from the asset wallet, once per
// request ID. The backing wallet pays for the anchor transaction.
func (c *Client) SendAsset(ctx context.Context, req SendAssetRequest) (
*AssetSend, error) {

resp, err := c.daemon.SendAsset(ctx, &waverpc.SendAssetRequest{
RequestId: req.RequestID,
Address: req.Address,
Amount: uint64(req.Amount),
SatPerVbyte: req.SatPerVByte,
})
if err != nil {
return nil, fmt.Errorf("send asset: %w", err)
}

return assetSendFromProto(resp), nil
}

// ListAssetSends returns the sends of the asset wallet, oldest first.
func (c *Client) ListAssetSends(ctx context.Context) ([]AssetSend, error) {
resp, err := c.daemon.ListAssetSends(
ctx, &waverpc.ListAssetSendsRequest{},
)
if err != nil {
return nil, fmt.Errorf("list asset sends: %w", err)
}

sends := make([]AssetSend, 0, len(resp.GetSends()))
for _, send := range resp.GetSends() {
sends = append(sends, *assetSendFromProto(send))
}

return sends, nil
}

// DepositAsset funds a boarding output holding a Taproot Asset, or resumes
// the deposit with the same request ID.
func (c *Client) DepositAsset(ctx context.Context, req DepositAssetRequest) (
Expand Down Expand Up @@ -385,6 +528,19 @@ func assetReceiveFromProto(receive *waverpc.AssetReceive) *AssetReceive {
}
}

// assetSendFromProto converts an asset send to its wrapper type.
func assetSendFromProto(send *waverpc.AssetSend) *AssetSend {
return &AssetSend{
RequestID: send.GetRequestId(),
AnchorTxid: send.GetAnchorTxid(),
AssetRef: send.GetAssetRef(),
Amount: AssetUnits(send.GetAmount()),
ChainFeeSat: send.GetChainFeeSat(),
ConfirmationHeight: send.GetConfirmationHeight(),
Timestamp: send.GetTimestamp(),
}
}

// assetDepositFromProto converts an asset deposit to its wrapper type.
func assetDepositFromProto(deposit *waverpc.AssetDeposit) *AssetDeposit {
var status string
Expand Down
38 changes: 38 additions & 0 deletions sdk/wavewalletdk/assets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,44 @@ func TestAssetReceiveFromProto(t *testing.T) {
}
}

// TestAssetSendFromProto maps a send to the wrapper type, and decodes a send
// request whose amount is a decimal string.
func TestAssetSendFromProto(t *testing.T) {
t.Parallel()

send := assetSendFromProto(&waverpc.AssetSend{
RequestId: "pay-1",
AnchorTxid: "cc",
AssetRef: "tapr1ref",
Amount: 1<<53 + 1,
ChainFeeSat: 715,
ConfirmationHeight: 121,
Timestamp: 1_700_000_000,
})
require.Equal(t, &AssetSend{
RequestID: "pay-1",
AnchorTxid: "cc",
AssetRef: "tapr1ref",
Amount: 1<<53 + 1,
ChainFeeSat: 715,
ConfirmationHeight: 121,
Timestamp: 1_700_000_000,
}, send)

var (
req SendAssetRequest
decoded any = &req
)
reqJSON := `{"RequestID":"pay-1","Address":"taprt1addr",` +
`"Amount":"9007199254740993"}`
require.NoError(t, json.Unmarshal([]byte(reqJSON), decoded))
require.Equal(t, SendAssetRequest{
RequestID: "pay-1",
Address: "taprt1addr",
Amount: 1<<53 + 1,
}, req)
}

// TestAssetDepositFromProto maps a deposit and its lifecycle stage to the
// wrapper type.
func TestAssetDepositFromProto(t *testing.T) {
Expand Down
Loading
Loading