@@ -541,209 +541,7 @@ enum ChangeSpendPolicy {
541541 "ChangeForbidden"
542542};
543543
544- interface Wallet {
545- [Throws=CreateWithPersistError]
546- constructor(Descriptor descriptor, Descriptor change_descriptor, Network network, Connection connection);
547-
548- [Name=load, Throws=LoadWithPersistError]
549- constructor(Descriptor descriptor, Descriptor change_descriptor, Connection connection);
550-
551- /// Informs the wallet that you no longer intend to broadcast a tx that was built from it.
552- ///
553- /// This frees up the change address used when creating the tx for use in future transactions.
554- void cancel_tx([ByRef] Transaction tx);
555-
556- /// The derivation index of this wallet. It will return `None` if it has not derived any addresses.
557- /// Otherwise, it will return the index of the highest address it has derived.
558- u32? derivation_index(KeychainKind keychain);
559-
560- /// Returns the utxo owned by this wallet corresponding to `outpoint` if it exists in the
561- /// wallet's database.
562- LocalOutput? get_utxo(OutPoint op);
563-
564- /// Finds how the wallet derived the script pubkey `spk`.
565- ///
566- /// Will only return `Some(_)` if the wallet has given out the spk.
567- KeychainAndIndex? derivation_of_spk(Script spk);
568-
569- /// Attempt to reveal the next address of the given `keychain`.
570- ///
571- /// This will increment the keychain's derivation index. If the keychain's descriptor doesn't
572- /// contain a wildcard or every address is already revealed up to the maximum derivation
573- /// index defined in [BIP32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki),
574- /// then the last revealed address will be returned.
575- AddressInfo reveal_next_address(KeychainKind keychain);
576-
577- /// Peek an address of the given `keychain` at `index` without revealing it.
578- ///
579- /// For non-wildcard descriptors this returns the same address at every provided index.
580- ///
581- /// # Panics
582- ///
583- /// This panics when the caller requests for an address of derivation index greater than the
584- /// [BIP32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki) max index.
585- AddressInfo peek_address(KeychainKind keychain, u32 index);
586-
587- /// The index of the next address that you would get if you were to ask the wallet for a new address
588- u32 next_derivation_index(KeychainKind keychain);
589-
590- /// Get the next unused address for the given `keychain`, i.e. the address with the lowest
591- /// derivation index that hasn't been used in a transaction.
592- ///
593- /// This will attempt to reveal a new address if all previously revealed addresses have
594- /// been used, in which case the returned address will be the same as calling [`Wallet::reveal_next_address`].
595- ///
596- /// **WARNING**: To avoid address reuse you must persist the changes resulting from one or more
597- /// calls to this method before closing the wallet. See [`Wallet::reveal_next_address`].
598- AddressInfo next_unused_address(KeychainKind keychain);
599-
600- /// Marks an address used of the given `keychain` at `index`.
601- ///
602- /// Returns whether the given index was present and then removed from the unused set.
603- boolean mark_used(KeychainKind keychain, u32 index);
604-
605- /// Reveal addresses up to and including the target `index` and return an iterator
606- /// of newly revealed addresses.
607- ///
608- /// If the target `index` is unreachable, we make a best effort to reveal up to the last
609- /// possible index. If all addresses up to the given `index` are already revealed, then
610- /// no new addresses are returned.
611- ///
612- /// **WARNING**: To avoid address reuse you must persist the changes resulting from one or more
613- /// calls to this method before closing the wallet. See [`Wallet::reveal_next_address`].
614- sequence<AddressInfo> reveal_addresses_to(KeychainKind keychain, u32 index);
615-
616- /// List addresses that are revealed but unused.
617- ///
618- /// Note if the returned iterator is empty you can reveal more addresses
619- /// by using [`reveal_next_address`](Self::reveal_next_address) or
620- /// [`reveal_addresses_to`](Self::reveal_addresses_to).
621- sequence<AddressInfo> list_unused_addresses(KeychainKind keychain);
622-
623- /// Get the Bitcoin network the wallet is using.
624- Network network();
625-
626- /// Return the checksum of the public descriptor associated to `keychain`
627- ///
628- /// Internally calls [`Self::public_descriptor`] to fetch the right descriptor
629- string descriptor_checksum(KeychainKind keychain);
630-
631- [Throws=DescriptorError]
632- Policy? policies(KeychainKind keychain);
633-
634- /// Return the balance, separated into available, trusted-pending, untrusted-pending and immature
635- /// values.
636- Balance balance();
637-
638- /// Applies an update to the wallet and stages the changes (but does not persist them).
639- ///
640- /// Usually you create an `update` by interacting with some blockchain data source and inserting
641- /// transactions related to your wallet into it.
642- ///
643- /// After applying updates you should persist the staged wallet changes. For an example of how
644- /// to persist staged wallet changes see [`Wallet::reveal_next_address`].
645- [Throws=CannotConnectError]
646- void apply_update(Update update);
647-
648- /// Return whether or not a `script` is part of this wallet (either internal or external)
649- boolean is_mine(Script script);
650-
651- /// Sign a transaction with all the wallet's signers, in the order specified by every signer's
652- /// [`SignerOrdering`]. This function returns the `Result` type with an encapsulated `bool` that has the value true if the PSBT was finalized, or false otherwise.
653- ///
654- /// The [`SignOptions`] can be used to tweak the behavior of the software signers, and the way
655- /// the transaction is finalized at the end. Note that it can't be guaranteed that *every*
656- /// signers will follow the options, but the "software signers" (WIF keys and `xprv`) defined
657- /// in this library will.
658- [Throws=SignerError]
659- boolean sign(Psbt psbt, optional SignOptions? sign_options = null);
660-
661- /// Finalize a PSBT, i.e., for each input determine if sufficient data is available to pass
662- /// validation and construct the respective `scriptSig` or `scriptWitness`. Please refer to
663- /// [BIP174](https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki#Input_Finalizer),
664- /// and [BIP371](https://github.com/bitcoin/bips/blob/master/bip-0371.mediawiki)
665- /// for further information.
666- ///
667- /// Returns `true` if the PSBT could be finalized, and `false` otherwise.
668- ///
669- /// The [`SignOptions`] can be used to tweak the behavior of the finalizer.
670- [Throws=SignerError]
671- boolean finalize_psbt(Psbt psbt, optional SignOptions? sign_options = null);
672-
673- /// Compute the `tx`'s sent and received [`Amount`]s.
674- ///
675- /// This method returns a tuple `(sent, received)`. Sent is the sum of the txin amounts
676- /// that spend from previous txouts tracked by this wallet. Received is the summation
677- /// of this tx's outputs that send to script pubkeys tracked by this wallet.
678- SentAndReceivedValues sent_and_received([ByRef] Transaction tx);
679-
680- /// Iterate over the transactions in the wallet.
681- sequence<CanonicalTx> transactions();
682-
683- /// Get a single transaction from the wallet as a [`WalletTx`] (if the transaction exists).
684- ///
685- /// `WalletTx` contains the full transaction alongside meta-data such as:
686- /// * Blocks that the transaction is [`Anchor`]ed in. These may or may not be blocks that exist
687- /// in the best chain.
688- /// * The [`ChainPosition`] of the transaction in the best chain - whether the transaction is
689- /// confirmed or unconfirmed. If the transaction is confirmed, the anchor which proves the
690- /// confirmation is provided. If the transaction is unconfirmed, the unix timestamp of when
691- /// the transaction was last seen in the mempool is provided.
692- [Throws=TxidParseError]
693- CanonicalTx? get_tx(string txid);
694-
695- /// Calculates the fee of a given transaction. Returns [`Amount::ZERO`] if `tx` is a coinbase transaction.
696- ///
697- /// To calculate the fee for a [`Transaction`] with inputs not owned by this wallet you must
698- /// manually insert the TxOut(s) into the tx graph using the [`insert_txout`] function.
699- ///
700- /// Note `tx` does not have to be in the graph for this to work.
701- [Throws=CalculateFeeError]
702- Amount calculate_fee([ByRef] Transaction tx);
703-
704- /// Calculate the [`FeeRate`] for a given transaction.
705- ///
706- /// To calculate the fee rate for a [`Transaction`] with inputs not owned by this wallet you must
707- /// manually insert the TxOut(s) into the tx graph using the [`insert_txout`] function.
708- ///
709- /// Note `tx` does not have to be in the graph for this to work.
710- [Throws=CalculateFeeError]
711- FeeRate calculate_fee_rate([ByRef] Transaction tx);
712-
713- /// Return the list of unspent outputs of this wallet
714- sequence<LocalOutput> list_unspent();
715-
716- /// List all relevant outputs (includes both spent and unspent, confirmed and unconfirmed).
717- ///
718- /// To list only unspent outputs (UTXOs), use [`Wallet::list_unspent`] instead.
719- sequence<LocalOutput> list_output();
720-
721- /// Create a [`FullScanRequest] for this wallet.
722- ///
723- /// This is the first step when performing a spk-based wallet full scan, the returned
724- /// [`FullScanRequest] collects iterators for the wallet's keychain script pub keys needed to
725- /// start a blockchain full scan with a spk based blockchain client.
726- ///
727- /// This operation is generally only used when importing or restoring a previously used wallet
728- /// in which the list of used scripts is not known.
729- FullScanRequestBuilder start_full_scan();
730-
731- /// Create a partial [`SyncRequest`] for this wallet for all revealed spks.
732- ///
733- /// This is the first step when performing a spk-based wallet partial sync, the returned
734- /// [`SyncRequest`] collects all revealed script pubkeys from the wallet keychain needed to
735- /// start a blockchain sync with a spk based blockchain client.
736- SyncRequestBuilder start_sync_with_revealed_spks();
737-
738- [Throws=SqliteError]
739- boolean persist(Connection connection);
740-
741- /// Apply relevant unconfirmed transactions to the wallet.
742- /// Transactions that are not relevant are filtered out.
743- void apply_unconfirmed_txs(sequence<UnconfirmedTx> unconfirmed_txs);
744- };
745-
746- typedef dictionary UnconfirmedTx;
544+ typedef interface Wallet;
747545
748546interface Update {};
749547
0 commit comments