Skip to content

multi: add BIP-322 support#2517

Closed
asheswook wants to merge 17 commits into
btcsuite:masterfrom
asheswook:master
Closed

multi: add BIP-322 support#2517
asheswook wants to merge 17 commits into
btcsuite:masterfrom
asheswook:master

Conversation

@asheswook

@asheswook asheswook commented Apr 2, 2026

Copy link
Copy Markdown

Change Description

Implements BIP-322.

Closes #2077

Details

  • btcdutil/message: extract legacy message signing (BIP-137) into reusable package
  • btcutil/bip322: BIP-322 implementation supporting P2WPKH, P2TR, P2SH-P2WPKH, P2PKH (sign + verify) and P2WSH (verify only)
  • btcjson: add optional address parameter to SignMessageWithPrivKey
  • rpcserver: SignMessageWithPrivKey supports BIP-322 signing when address is provided; verifymessage tries legacy first, then BIP-322

Steps to Test

cd btcutil/bip322 && go test ./... -v -count=1
cd btcjson && go test -run TestChainSvrCmds -v -count=1
go build ./...

Pull Request Checklist

Testing

  • Your PR passes all CI checks.
  • Tests covering the positive and negative (error paths) are included.
  • Bug fixes contain tests triggering the bug to prevent regressions.

Code Style and Documentation

📝 Please see our Contribution Guidelines for further guidance.

@asheswook asheswook force-pushed the master branch 2 times, most recently from 84e9099 to 79a96b0 Compare April 2, 2026 13:17
@asheswook

Copy link
Copy Markdown
Author

CI fails with Failed to generate help for method 'signmessagewithprivkey': signmessagewithprivkey-address because of the TestHelp in rpcserverhelp.go. I'm gonna fix it.

@asheswook

Copy link
Copy Markdown
Author

I fixed that and works well. Also more tests added

@ThomsenDrake

Copy link
Copy Markdown

Following the BIP-322 signing implementation in #2521 — this PR adds BIP-322 support to the RPC server layer. One question on the architecture: #2521 implements bip322 as a btcutil submodule with Sign/Verify at the library level, while this PR adds RPC server methods. Are these two efforts coordinated — i.e., does this PR use the btcutil/bip322 module from #2521, or implement signing independently?

From a btcpay-mcp integration standpoint, having BIP-322 signing available both as a library call (btcutil/bip322 Sign/Verify) and as an RPC (signmessagewithprivkey BIP-322 mode) would give us two useful abstractions. Library-level for agentic challenge-response auth (SEP-1686 flow), RPC-level for wallet-style message signing.

Curious whether the RPC server approach here and the library approach in #2521 are meant to complement each other or if this PR subsumes the library work.

@asheswook

Copy link
Copy Markdown
Author

This PR is independent of #2521, adds the same implementation, but the two PRs are not related.
This is implements btcutil/bip322 module and adds RPC methods.

@asheswook

Copy link
Copy Markdown
Author

It seems that other PR is going on merge, so I'm gonna close this.

@asheswook asheswook closed this May 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BIP 322 Support

2 participants