Skip to content

Minor API break by Bitcoin Core wallet #414

@darosior

Description

@darosior

For the managers' CPFP we let the Bitcoin Core wallet do the work. For this we use walletprocesspsbt and specify the information within the PSBT. But Bitcoin Core will ignore the sighash type specified inside the PSBT inputs. So we were implicitly relying on the default value of the sighash_type parameter of the walletprocesspsbt which happened to be what we wanted (SIGHASH_ALL). bitcoin/bitcoin#22514 changed the default to SIGHASH_DEFAULT, which breaks our usage.

The fix is trivial, and backward compatible with previous versions of bitcoind. We need to explicitly specify the sighash_type parameter when calling walletprocesspsbt:

/// Make bitcoind:
/// 1. Add information to the PSBT inputs
/// 2. Sign the PSBT inputs it can
/// 3. Finalize the PSBT if it is complete
pub fn sign_psbt(&self, psbt: &Psbt) -> Result<(bool, Psbt), BitcoindError> {
let res = self.make_cpfp_request(
"walletprocesspsbt",
&params!(Json::String(base64::encode(&encode::serialize(psbt)))),
)?;
let complete = res
.get("complete")
.expect("API break: no 'complete' in 'walletprocesspsbt' result")
.as_bool()
.expect("API break: invalid 'complete' in 'walletprocesspsbt' result");
let psbt = res
.get("psbt")
.expect("API break: no 'psbt' in 'walletprocesspsbt' result")
.as_str()
.expect("API break: invalid 'psbt' in 'walletprocesspsbt' result")
.to_string();
let psbt =
encode::deserialize(&base64::decode(psbt).expect("bitcoind returned invalid base64"))
.expect("bitcoind returned an invalid PSBT.");
Ok((complete, psbt))
}

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions