JSPM

@rsksmart/btc-transaction-solidity-helper

0.2.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q67593F
  • License ISC

Solidity library with functions to work with Bitcoin transactions inside smart contracts

Package Exports

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@rsksmart/btc-transaction-solidity-helper) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    Bitcoin Transaction Solidity Helper

    OpenSSF Scorecard

    The intention of this library is to make easier to work with Bitcoin transactions in Solidity smart contracts. Since Rootstock extends Bitcoin's capabilities by enabling smart contracts it is important to be able to work with Bitcoin transactions in them.

    Features

    The features of this library include:

    • Bitcoin transaction output parsing: is able to receive a raw tx and return an array of structures with the tx outputs
    • Bitcoin transaction hashing: is able to receive a raw tx and return its hash
    • Bitcoin transaction output script validation: is able to receive a raw output script, validate that is from a specific type and return a result. E.g. receive a raw null-data script and return the embedded data in it
    • Bitcoin address generation: is able to generate Bitcoin the address from a specific script and also to validate if a given address was generated from a script or not.
    • Bitcoin address validation: is able to validate if a Bitcoin address is of a given type or not.

    Future features

    These are some features that can increase the library capabilities in the future:

    • Bitcoin transaction input parsing: should be able to receive a raw tx and return an array of structs with the tx inputs
    • Bitcoin transaction creation: utilities for building a raw transaction inside a contract

    Usage

    1. Run this command to install the contracts
       npm install @rsksmart/btc-transaction-solidity-helper
    1. Import the library in your contract
       import "@rsksmart/btc-transaction-solidity-helper/contracts/BtcUtils.sol";
    1. Use the library. E.g.:
       BtcUtils.TxRawOutput[] memory outputs = BtcUtils.getOutputs(btcTx);
       bytes memory btcTxDestination = BtcUtils.parseNullDataScript(outputs[0].pkScript, false);