andreabonel / node-elements

Typescript/node bindings for Elements, using bcrpc

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

node-elements

Typescript/node bindings for Elements, using bcrpc.

Installation:

$ node install --save node-elements

For typescript, you also want @types/node-elements.

Example:

// dict helper
const KV = (k, v) => {
    const kv = {};
    kv[k] = v;
    return kv;
};
// get a new confidential address from elements
const addr = await GetNewAddress();
// fetch the addressinfo, and get the scriptPubKey from it
const spk = (await GetAddressInfo(addr)).scriptPubKey;
// create a new raw transaction sending amount to the address
const crtres: string = await elements.CreateRawTransaction([], KV(addr, amount));
// fund it
const { hex, fee, changepos } = await elements.FundRawTransaction(crtres);
// ...

About

Typescript/node bindings for Elements, using bcrpc

License:MIT License


Languages

Language:TypeScript 95.3%Language:JavaScript 4.7%