8000 Regtest-like mock node interface · Issue #57 · shesek/minsc · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Regtest-like mock node interface #57
Open
@shesek

Description

@shesek

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

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0