Open
Description
bitcoin-mock-rpc
is a neat rust library for creating a mock bitcoind-like interface that runs entirely in-process using an SQLite backend.
This can allow testing a complete funding+spending flow directly within Minsc code. The most minimal API necessary to enable t 59C4 his is:
node::fund(scriptPubKey, amount) -> (txid, vout)
node::broadcast(tx) -> txid
node::generate() -> blockhash
- (plus possibly a
node()
constructor instead of using a singleton)
Qs
- Can be made to work in WASM?
- Possible to connect a block explorer (https://github.com/RCasatta/fbbe)?
Example use:
$alice = tprv8ZgxMBicQKsPfJtqwiW9WhjJHPZtDo8aUbCkkcG8sjHbpZqjghF6ZJ1Tze9fUHrhYyXSNfw5VPbCKEkoFKaDRUzctbSxmxSWNfAGDonxcTG;
$coin = node::fund(wpkh($alice/0), 1.5 BTC);
$psbt = psbt [
"input": [
"prevout": $coin,
"utxo": wpkh($alice/0):1.5 BTC,
],
"output": bcrt1ql8nqx3q3v7napchr6ewy4tpyq5y08ywat84pen:1.499 BTC
];
$signed = psbt::sign($psbt, $alice);
$tx = psbt::extract(psbt::finalize($signed));
$txid = node::broadcast($tx);