|
| 1 | +syntax = "proto3"; |
| 2 | + |
| 3 | +import "taprootassets.proto"; |
| 4 | + |
| 5 | +package assetwalletrpc; |
| 6 | + |
| 7 | +option go_package = "github.com/lightninglabs/taproot-assets/taprpc/assetwalletrpc"; |
| 8 | + |
| 9 | +service AssetWallet { |
| 10 | + /* |
| 11 | + FundVirtualPsbt selects inputs from the available asset commitments to fund |
| 12 | + a virtual transaction matching the template. |
| 13 | + */ |
| 14 | + rpc FundVirtualPsbt (FundVirtualPsbtRequest) |
| 15 | + returns (FundVirtualPsbtResponse); |
| 16 | + |
| 17 | + /* |
| 18 | + SignVirtualPsbt signs the inputs of a virtual transaction and prepares the |
| 19 | + commitments of the inputs and outputs. |
| 20 | + */ |
| 21 | + rpc SignVirtualPsbt (SignVirtualPsbtRequest) |
| 22 | + returns (SignVirtualPsbtResponse); |
| 23 | + |
| 24 | + /* |
| 25 | + AnchorVirtualPsbts merges and then commits multiple virtual transactions in |
| 26 | + a single BTC level anchor transaction. |
| 27 | +
|
| 28 | + TODO(guggero): Actually implement accepting and merging multiple |
| 29 | + transactions. |
| 30 | + */ |
| 31 | + rpc AnchorVirtualPsbts (AnchorVirtualPsbtsRequest) |
| 32 | + returns (taprpc.SendAssetResponse); |
| 33 | + |
| 34 | + /* |
| 35 | + NextInternalKey derives the next internal key for the given key family and |
| 36 | + stores it as an internal key in the database to make sure it is identified |
| 37 | + as a local key later on when importing proofs. While an internal key can |
| 38 | + also be used as the internal key of a script key, it is recommended to use |
| 39 | + the NextScriptKey RPC instead, to make sure the tweaked Taproot output key |
| 40 | + is also recognized as a local key. |
| 41 | + */ |
| 42 | + rpc NextInternalKey (NextInternalKeyRequest) |
| 43 | + returns (NextInternalKeyResponse); |
| 44 | + |
| 45 | + /* |
| 46 | + NextScriptKey derives the next script key (and its corresponding internal |
| 47 | + key) and stores them both in the database to make sure they are identified |
| 48 | + as local keys later on when importing proofs. |
| 49 | + */ |
| 50 | + rpc NextScriptKey (NextScriptKeyRequest) returns (NextScriptKeyResponse); |
| 51 | + |
| 52 | + /* |
| 53 | + ProveAssetOwnership creates an ownership proof embedded in an asset |
| 54 | + transition proof. That ownership proof is a signed virtual transaction |
| 55 | + spending the asset with a valid witness to prove the prover owns the keys |
| 56 | + that can spend the asset. |
| 57 | + */ |
| 58 | + rpc ProveAssetOwnership (ProveAssetOwnershipRequest) |
| 59 | + returns (ProveAssetOwnershipResponse); |
| 60 | + |
| 61 | + /* |
| 62 | + VerifyAssetOwnership verifies the asset ownership proof embedded in the |
| 63 | + given transition proof of an asset and returns true if the proof is valid. |
| 64 | + */ |
| 65 | + rpc VerifyAssetOwnership (VerifyAssetOwnershipRequest) |
| 66 | + returns (VerifyAssetOwnershipResponse); |
| 67 | +} |
| 68 | + |
| 69 | +message FundVirtualPsbtRequest { |
| 70 | + oneof template { |
| 71 | + /* |
| 72 | + Use an existing PSBT packet as the template for the funded PSBT. |
| 73 | +
|
| 74 | + TODO(guggero): Actually implement this. We can't use the "reserved" |
| 75 | + keyword here because we're in a oneof, so we add the field but implement |
| 76 | + it later. |
| 77 | + */ |
| 78 | + bytes psbt = 1; |
| 79 | + |
| 80 | + /* |
| 81 | + Use the asset outputs and optional asset inputs from this raw template. |
| 82 | + */ |
| 83 | + TxTemplate raw = 2; |
| 84 | + } |
| 85 | +} |
| 86 | + |
| 87 | +message FundVirtualPsbtResponse { |
| 88 | + /* |
| 89 | + The funded but not yet signed PSBT packet. |
| 90 | + */ |
| 91 | + bytes funded_psbt = 1; |
| 92 | + |
| 93 | + /* |
| 94 | + The index of the added change output or -1 if no change was left over. |
| 95 | + */ |
| 96 | + int32 change_output_index = 2; |
| 97 | +} |
| 98 | + |
| 99 | +message TxTemplate { |
| 100 | + /* |
| 101 | + An optional list of inputs to use. Every input must be an asset UTXO known |
| 102 | + to the wallet. The sum of all inputs must be greater than or equal to the |
| 103 | + sum of all outputs. |
| 104 | +
|
| 105 | + If no inputs are specified, asset coin selection will be performed instead |
| 106 | + and inputs of sufficient value will be added to the resulting PSBT. |
| 107 | + */ |
| 108 | + repeated PrevId inputs = 1; |
| 109 | + |
| 110 | + /* |
| 111 | + A map of all Taproot Asset addresses mapped to the anchor transaction's |
| 112 | + output index that should be sent to. |
| 113 | + */ |
| 114 | + map<string, uint64> recipients = 2; |
| 115 | +} |
| 116 | + |
| 117 | +message PrevId { |
| 118 | + /* |
| 119 | + The bitcoin anchor output on chain that contains the input asset. |
| 120 | + */ |
| 121 | + OutPoint outpoint = 1; |
| 122 | + |
| 123 | + /* |
| 124 | + The asset ID of the previous asset tree. |
| 125 | + */ |
| 126 | + bytes id = 2; |
| 127 | + |
| 128 | + /* |
| 129 | + The tweaked Taproot output key committing to the possible spending |
| 130 | + conditions of the asset. |
| 131 | + */ |
| 132 | + bytes script_key = 3; |
| 133 | +} |
| 134 | + |
| 135 | +message OutPoint { |
| 136 | + /* |
| 137 | + Raw bytes representing the transaction id. |
| 138 | + */ |
| 139 | + bytes txid = 1; |
| 140 | + |
| 141 | + /* |
| 142 | + The index of the output on the transaction. |
| 143 | + */ |
| 144 | + uint32 output_index = 2; |
| 145 | +} |
| 146 | + |
| 147 | +message SignVirtualPsbtRequest { |
| 148 | + /* |
| 149 | + The PSBT of the virtual transaction that should be signed. The PSBT must |
| 150 | + contain all required inputs, outputs, UTXO data and custom fields required |
| 151 | + to identify the signing key. |
| 152 | + */ |
| 153 | + bytes funded_psbt = 1; |
| 154 | +} |
| 155 | + |
| 156 | +message SignVirtualPsbtResponse { |
| 157 | + /* |
| 158 | + The signed virtual transaction in PSBT format. |
| 159 | + */ |
| 160 | + bytes signed_psbt = 1; |
| 161 | + |
| 162 | + /* |
| 163 | + The indices of signed inputs. |
| 164 | + */ |
| 165 | + repeated uint32 signed_inputs = 2; |
| 166 | +} |
| 167 | + |
| 168 | +message AnchorVirtualPsbtsRequest { |
| 169 | + /* |
| 170 | + The list of virtual transactions that should be merged and committed to in |
| 171 | + the BTC level anchor transaction. |
| 172 | + */ |
| 173 | + repeated bytes virtual_psbts = 1; |
| 174 | +} |
| 175 | + |
| 176 | +message NextInternalKeyRequest { |
| 177 | + uint32 key_family = 1; |
| 178 | +} |
| 179 | + |
| 180 | +message NextInternalKeyResponse { |
| 181 | + taprpc.KeyDescriptor internal_key = 1; |
| 182 | +} |
| 183 | + |
| 184 | +message NextScriptKeyRequest { |
| 185 | + uint32 key_family = 1; |
| 186 | +} |
| 187 | + |
| 188 | +message NextScriptKeyResponse { |
| 189 | + taprpc.ScriptKey script_key = 1; |
| 190 | +} |
| 191 | + |
| 192 | +message ProveAssetOwnershipRequest { |
| 193 | + bytes asset_id = 1; |
| 194 | + |
| 195 | + bytes script_key = 2; |
| 196 | +} |
| 197 | + |
| 198 | +message ProveAssetOwnershipResponse { |
| 199 | + bytes proof_with_witness = 1; |
| 200 | +} |
| 201 | + |
| 202 | +message VerifyAssetOwnershipRequest { |
| 203 | + bytes proof_with_witness = 1; |
| 204 | +} |
| 205 | + |
| 206 | +message VerifyAssetOwnershipResponse { |
| 207 | + bool valid_proof = 1; |
| 208 | +} |
0 commit comments