Socket
Socket
Sign inDemoInstall

bip174

Package Overview
Dependencies
Maintainers
3
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bip174

[![Build Status](https://travis-ci.org/bitcoinjs/bip174.png?branch=master)](https://travis-ci.org/bitcoinjs/bip174) [![NPM](https://img.shields.io/npm/v/bip174.svg)](https://www.npmjs.org/package/bip174)


Version published
Weekly downloads
114K
decreased by-34.09%
Maintainers
3
Weekly downloads
 
Created

What is bip174?

The bip174 npm package is a library for handling Partially Signed Bitcoin Transactions (PSBT) as defined by BIP 174. It provides tools to create, modify, and finalize PSBTs, which are useful for multi-party transaction signing and other advanced Bitcoin transaction workflows.

What are bip174's main functionalities?

Create a PSBT

This feature allows you to create a new PSBT by adding inputs and outputs. The code sample demonstrates how to initialize a PSBT, add an input with a transaction hash and index, and add an output with a recipient address and value.

const { Psbt } = require('bip174');
const psbt = new Psbt();
psbt.addInput({
  hash: 'transactionHash',
  index: 0,
  nonWitnessUtxo: Buffer.from('hexString', 'hex')
});
psbt.addOutput({
  address: 'recipientAddress',
  value: 1000
});
console.log(psbt.toBase64());

Sign a PSBT

This feature allows you to sign a PSBT. The code sample demonstrates how to load a PSBT from a base64 string, create a key pair, and sign the first input of the PSBT.

const { Psbt } = require('bip174');
const psbt = Psbt.fromBase64('base64PsbtString');
const keyPair = { publicKey: Buffer.from('publicKeyHex', 'hex'), privateKey: Buffer.from('privateKeyHex', 'hex') };
psbt.signInput(0, keyPair);
console.log(psbt.toBase64());

Finalize a PSBT

This feature allows you to finalize a PSBT and extract the final transaction. The code sample demonstrates how to load a PSBT from a base64 string, finalize all inputs, and extract the final transaction in hexadecimal format.

const { Psbt } = require('bip174');
const psbt = Psbt.fromBase64('base64PsbtString');
psbt.finalizeAllInputs();
const tx = psbt.extractTransaction();
console.log(tx.toHex());

Other packages similar to bip174

FAQs

Package last updated on 04 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc