In this directory you can find examples of how to use the spv-wallet-go-client
package.
- You have access to the
spv-wallet
non-custodial wallet (running locally or remotely). - You have installed this package on your machine (
go install
on this project's root directory).
- The
ExampleAdminKey
defined inexample_keys.go
is the default one from spv-wallet-web-backend repository- If in your current
spv-wallet
instance you have a differentadminKey
, you should replace the one inexample_keys
with the one you have.
- If in your current
- The
ExampleXPub
andExampleXPriv
are just placeholders, which won't work.- You should replace them by newly generated ones using
task generate_keys
, - ... or use your actual keys if you have them (don't use the keys which are already added to another wallet).
- You should replace them by newly generated ones using
Additionally, to make it work properly, you should adjust the
ExamplePaymail
to align with yourdomains
configuration in thespv-wallet
instance.
generate_keys
- generates new keys (you can copy them toexample_keys
if you want to use them in next examples)admin_add_user
- adds a new user (more precisely addsExampleXPub
and thenExamplePaymail
to the wallet)
To fully experience the next steps, it would be beneficial to transfer some funds to your
ExamplePaymail
. This ensures the examples run smoothly by demonstrating the creation of a transaction with an actual balance. You can transfer funds to yourExamplePaymail
using a Bitcoin SV wallet application such as HandCash or any other that supports Paymail.
get_balance
- checks the balance - if you've transferred funds to yourExamplePaymail
, you should see them herecreate_transaction
- creates a transaction (you can adjust theoutputs
to your needs)list_transactions
- lists all transactions and with example filteringsend_op_return
- sends an OP_RETURN transactionadmin_remove_user
- removes the user
In addition to the above, there are additional examples showing how to use the client from a developer perspective:
handle_exceptions
- presents how to "catch" exceptions which the client can throw
xpriv_from_mnemonic
- allows you to generate/extract an xPriv key from a mnemonic phrase. To you use it you just need to replace themnemonic
variable with your own mnemonic phrase.xpub_from_xpriv
- allows you to generate an xPub key from an xPriv key. To you use it you just need to replace thexPriv
variable with your own xPriv key.generate_totp
- allows you to generate and check validity of a TOTP code for client xPriv and a contact's PKI
The examples are written in Go and can be run by:
cd examples
task name_of_the_example
See the
examples/Taskfile.yml
for the list of available examples and scripts