Skip to content

Commit 0884a8d

Browse files
committed
docs(wallet): document Wallet::sign_psbt usage and requirement
1 parent 808b1f3 commit 0884a8d

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

src/wallet/mod.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1802,6 +1802,27 @@ impl Wallet {
18021802
}
18031803
}
18041804

1805+
/// Sign a PSBT using an external key provider via [`bitcoin::Psbt::sign`].
1806+
///
1807+
/// This is a thin wrapper around [`bitcoin::Psbt::sign`] that supplies the wallet's
1808+
/// internal [`secp256k1`] context. It lets callers sign with any type that implements
1809+
/// [`psbt::GetKey`], such as [`bitcoin::bip32::Xpriv`], without having to manage their
1810+
/// own secp256k1 context.
1811+
///
1812+
/// # BIP32 derivation metadata
1813+
///
1814+
/// [`bitcoin::Psbt::sign`] uses the `bip32_derivation` fields (for legacy and segwit inputs)
1815+
/// or the `tap_key_origins` fields (for taproot inputs) in each PSBT input to locate
1816+
/// the correct child keys. PSBTs received from external coordinator tools or
1817+
/// hardware wallet flows typically carry this metadata already.
1818+
///
1819+
/// # Returns
1820+
///
1821+
/// On success, a [`psbt::SigningKeysMap`] mapping each signed input index to the keys
1822+
/// that were used. On failure, a tuple of the partial success map and a
1823+
/// [`psbt::SigningErrors`] map of per-input errors.
1824+
///
1825+
/// [`secp256k1`]: bitcoin::secp256k1
18051826
pub fn sign_psbt<K>(
18061827
&self,
18071828
psbt: &mut Psbt,

0 commit comments

Comments
 (0)