示例#1
0
async function main() {
  var wallet, acct, mtx, tx, wtx;

  await walletdb.open();

  wallet = await walletdb.create();

  console.log('Created wallet');
  console.log(wallet);

  acct = await wallet.createAccount({
    name: 'foo'
  });

  console.log('Created account');
  console.log(acct);

  mtx = new MTX();
  mtx.addOutpoint(dummy());
  mtx.addOutput(acct.getReceive(), 50460);
  tx = mtx.toTX();

  await walletdb.addTX(tx);

  wtx = await wallet.getTX(tx.hash('hex'));

  console.log('Added transaction');
  console.log(wtx);
}
示例#2
0
async function fundWallet(wdb, addr) {
  var tx, balance, receive, details;

  // Coinbase
  tx = new MTX();
  tx.addOutpoint(new Outpoint(encoding.NULL_HASH, 0));
  tx.addOutput(addr, 50460);
  tx.addOutput(addr, 50460);
  tx.addOutput(addr, 50460);
  tx.addOutput(addr, 50460);
  tx = tx.toTX();

  wallet.once('balance', function(balance) {
    console.log('New Balance:');
    console.log(balance);
  });

  wallet.once('address', function(receive) {
    console.log('New Receiving Address:');
    console.log(receive);
  });

  wallet.once('tx', function(details) {
    console.log('New Wallet TX:');
    console.log(details);
  });

  await wdb.addTX(tx);
  await co.timeout(300);
}