Code Monkey home page Code Monkey logo

psbt's Introduction

PSBTs

PSBTs are a format for communicating and collaboratively working with transactions.

The format is defined in BIP-0174: https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki

Methods

combinePsbts

Combine multiple PSBTs

{
  psbts: [<BIP 174 Encoded PSBT Hex String>]
}

@throws
<Combine PSBT Error>

@returns
{
  psbt: <BIP 174 Encoded PSBT Hex String>
}

createPsbt

Create a PSBT

{
  outputs: [{
    script: <Output ScriptPub Hex String>
    tokens: <Sending Tokens Number>
  }]
  utxos: [{
    id: <Transaction Id Hex String>
    [sequence]: <Sequence Number>
    vout: <Output Index Number>
  }]
  [timelock]: <Set Lock Time on Transaction To Number>
  [version]: <Transaction Version Number>
}

@returns
{
  psbt: <Partially Signed Bitcoin Transaction Hex Encoded String>
}

decodePsbt

Decode a BIP 174 encoded PSBT

{
  psbt: <Hex Encoded Partially Signed Bitcoin Transaction String>
}

@throws
<Invalid PSBT Error>

@returns
{
  inputs: [{
     [bip32_derivations]: [{
        fingerprint: <Public Key Fingerprint Hex String>
        path: <BIP 32 Child / Hardened Child / Index Derivation Path String>
        public_key: <Public Key Hex String>
    }]
    [final_scriptsig]: <Final ScriptSig Hex String>
    [final_scriptwitness]: <Final Script Witness Hex String>
    [non_witness_utxo]: <Non-Witness Hex Encoded Transaction String>
    [partial_sig]: [{
      hash_type: <Signature Hash Type Number>
      public_key: <Public Key Hex String>
      signature: <Signature Hex String>
    }]
    [redeem_script]: <Hex Encoded Redeem Script String>
    [sighash_type]: <Sighash Type Number>
    [unrecognized_attributes]: [{
      type: <Key Type Hex String>
      value: <Value Hex String>
    }]
    [witness_script]: <Witness Script Hex String>
    [witness_utxo]: {
      script_pub: <UTXO ScriptPub Hex String>
      tokens: <Tokens Number>
    }
  }]
  outputs: [{
    [bip32_derivation]: {
      fingerprint: <Public Key Fingerprint Hex String>
      path: <BIP 32 Child/HardenedChild/Index Derivation Path Hex String>
      public_key: <Public Key Hex String>
    }
    [redeem_script]: <Hex Encoded Redeem Script>
    [unrecognized_attributes]: [{
      type: <Key Type Hex String>
      value: <Value Hex String>
    }]
    [witness_script]: <Hex Encoded Witness Script>
  }]
  pairs: [{
    type: <Key Type Hex String>
    value: <Value Hex String>
  }]
  [unrecognized_attributes]: [{
    type: <Global Key Type Hex String>
    value: <Global Value Hex String>
  }]
  unsigned_transaction: <Unsigned Transaction Hex String>
}

encodePsbt

Encode a Partially Signed Bitcoin Transaction

{
  pairs: [{
    [separator]: <Is Separator Bool>
    [type]: <Type Buffer Object>
    [value]: <Value Buffer Object>
  }]
}

@throws
<Failed To Encode Error>

@returns
{
  psbt: <Hex Encoded Partially Signed Bitcoin Transaction String>
}

extractTransaction

Extract a transaction from a finalized PSBT

{
  psbt: <BIP 174 Encoded PSBT Hex String>
}

@throws
<Extract Transaction Error>

@returns
{
  transaction: <Hex Serialized Transaction String>
}

finalizePsbt

Finalize the inputs of a PSBT

{
  psbt: <BIP 174 Encoded PSBT Hex String>
}

@throws
<Finalize PSBT Error>

@returns
{
  psbt: <BIP 174 Encoded PSBT Hex String>
}

signPsbt

Update a PSBT with signatures

{
  network: <Network Name String>
  psbt: <BIP 174 Encoded PSBT Hex String>
  signing_keys: [<WIF Encoded Private Key String>]
}

@throws
<Sign PSBT Error>

@returns
{
  psbt: <BIP 174 Encoded PSBT Hex String>
}

transactionAsPsbt

Convert a signed transaction to a signed PSBT

Note: not all signed transactions can be converted to a signed PSBT. For example, a preimage cannot be represented in a standard PSBT.

{
  spending: [<Spending Transaction Hex String>]
  transaction: <Hex Encoded Transaction String>
}

@throws
<Error>

@returns
{
  psbt: <Signed PSBT String>
}

updatePsbt

Update a PSBT

{
  [additional_attributes]: [{
    type: <Type Hex String>
    value: <Value Hex String>
    vin: <Input Index Number>
    vout: <Output Index Number>
  }]
  [bip32_derivations]: [{
    fingerprint: <BIP 32 Fingerprint of Parent's Key Hex String>
    path: <BIP 32 Derivation Path String>
    public_key: <Public Key String>
  }]
  psbt: <BIP 174 Encoded PSBT String>
  [redeem_scripts]: [<Hex Encoded Redeem Script String>]
  [sighashes]: [{
    id: <Transaction Id String>
    sighash: <Sighash Flag Number>
    vout: <Spending Output Index Number>
  }]
  [signatures]: [{
    vin: <Signature Input Index Number>
    hash_type: <Signature Hash Type Number>
    public_key: <BIP 32 Public Key String>
    signature: <Signature Hex String>
  }]
  [transactions]: [<Hex Encoding Transaction String>]
  [witness_scripts]: [<Witness Script String>]
}

@throws
<Update PSBT Error>

@returns
{
  psbt: <Hex Encoded Partially Signed Bitcoin Transaction String>
}

psbt's People

Contributors

alexbosworth avatar dependabot[bot] avatar tiero avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.