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