-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support btc in wallet #11
Conversation
8a3d6a2
to
47492a7
Compare
2a72fc1
to
c7265ef
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
everything works from my testing — we can also add wallet balance support in another PR!
/// Generate a random secp256k1 private key, subject to the constraint that the | ||
/// public key partity is even. | ||
pub fn random_btc_secret_key() -> KeyInfo { | ||
let secret_key = loop { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can negate the secret key to negate its parity, instead of looping. But the libsecp256k1
doesn't provide the negate method (the underlying Scalar does but it's not public, annoying). So let's keep it this way.
@@ -99,6 +99,9 @@ impl CommandLineHandler for WalletBalances { | |||
println!("{:?} - Balance: {}", addr, balance); | |||
} | |||
} | |||
WalletType::Btc => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this use the same (except the wallet name) implementation as the evm wallet type? It looks like it forwards the request to the manager
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To handle in #16
Closes #9.
The
ipc-cli wallet
command can now generate keys that are compatible with bitcoin. A new valuebtc
was added for parameter--wallet-type
. The created key is similar to theevm
wallet type (secp256k1 keypair), with the only difference that the public key is even (as defined in libsecp256k1), as required by bitcoin's taproot.Here is how to use the new functionalities of the wallet:
ipc-cli wallet new --wallet-type btc
ipc-cli wallet list --wallet-type btc
output:
ipc-cli wallet pub-key --wallet-type btc --address 0x303d9fb576971313ebefd0afc085a21dd43de79d
output:
04b7a6d2916cf35d7c69e31e9bf169138d09536495f64e6bb84abc009b72a3b0d5d1440c977c3faf1b52ef58b5b0960309734364a3e577608db5717709d910c690
ipc-cli wallet set-default --wallet-type btc --address 0x303d9fb576971313ebefd0afc085a21dd43de79d
ipc-cli wallet get-default --wallet-type btc
ipc-cli wallet export --wallet-type btc --address 0x303d9fb576971313ebefd0afc085a21dd43de79d --hex
output:
45d08401bfa93d6f8ef8f489f0f0f7cccc6baaa7a46ba680eb3ae165df5f291d
-
ipc-cli wallet import --wallet-type btc --private-key 4c75ecd89d223417f7d46631ee1144ac16067be2de72801c5613e23a4d03f3dd
output:
0x23df81f399387e8972b5286489378f139088ea85
ipc-cli wallet remove --wallet-type btc --address 0x23df81f399387e8972b5286489378f139088ea85
ipc-cli wallet balances
is not supported yet.To create and join a subnet using the ipc wallet:
ipc-cli wallet new --wallet-type btc
ipc-cli wallet list --wallet-type btc
:XOnlyPublicKey
values. It will look like this:create
subcommand:join
subcommand 4 times, specifying each time one of the outputs ofwallet list
in the--from
argument. For example: