scoin

package scoin

Type members

Classlikes

object Addr extends BtcSerializer[Addr]
Companion:
class
Source:
Protocol.scala
case class Addr(addresses: Seq[NetworkAddressWithTimestamp]) extends BtcSerializable[Addr]
Companion:
object
Source:
Protocol.scala
object Base58

https://en.bitcoin.it/wiki/Base58Check_encoding Base58Check is a format based on Base58 and used a lot in bitcoin, for encoding addresses and private keys for example. It includes a prefix (usually a single byte) and a checksum so you know what has been encoded, and that it has been transmitted correctly. For example, to create an address for a public key you could write:

https://en.bitcoin.it/wiki/Base58Check_encoding Base58Check is a format based on Base58 and used a lot in bitcoin, for encoding addresses and private keys for example. It includes a prefix (usually a single byte) and a checksum so you know what has been encoded, and that it has been transmitted correctly. For example, to create an address for a public key you could write:

 val pub: BinaryData = "0202a406624211f2abbdc68da3df929f938c3399dd79fac1b51b0e4ad1d26a47aa"
 val address = Base58Check.encode(Base58.Prefix.PubkeyAddress, Crypto.hash160(pub))

And to decode a private key you could write:

 // check that is it a mainnet private key
 val (Base58.Prefix.SecretKey, priv) = Base58Check.decode("5J3mBbAH58CpQ3Y5RNJpUKPE62SQ5tfcvU2JpbnkeyhfsYB1Jcn")
Source:
Base58.scala
object Bech32

Bech32 and Bech32m address formats. See https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki and https://github.com/bitcoin/bips/blob/master/bip-0350.mediawiki.

object Block extends BtcSerializer[Block]
Companion:
class
Source:
Block.scala
case class Block(header: BlockHeader, tx: Seq[Transaction]) extends BtcSerializable[Block]

Bitcoin block

Bitcoin block

Value parameters:
header

block header

tx

transactions

Companion:
object
Source:
Block.scala
Companion:
class
Source:
Block.scala
case class BlockHeader(version: Long, hashPreviousBlock: ByteVector32, hashMerkleRoot: ByteVector32, time: Long, bits: Long, nonce: Long) extends BtcSerializable[BlockHeader]
Value parameters:
bits

The calculated difficulty target being used for this block

hashMerkleRoot

The reference to a Merkle tree collection which is a hash of all transactions related to this block

hashPreviousBlock

The hash value of the previous block this particular block references. Please not that this hash is not reversed (as opposed to Block.hash)

nonce

The nonce used to generate this block… to allow variations of the header and compute different hashes

time

A timestamp recording when this block was created (Will overflow in 2106[2])

version

Block version information, based upon the software version creating this block

Companion:
object
Source:
Block.scala
case class BlockHeight(underlying: Long) extends Ordered[BlockHeight]
case class Btc(underlying: BigDecimal) extends BtcAmount with Ordered[Btc]
sealed trait BtcAmount
Companion:
object
Source:
BtcAmount.scala
object BtcAmount
Companion:
class
Source:
BtcAmount.scala
final implicit class BtcDouble(n: Double) extends AnyVal
case class ByteVector32(bytes: ByteVector)

see https://en.bitcoin.it/wiki/Protocol_specification

Companion:
class
Source:
Protocol.scala
case class ByteVector64(bytes: ByteVector)
Companion:
object
Source:
Protocol.scala
Companion:
class
Source:
Protocol.scala
case class CltvExpiry(underlying: BlockHeight) extends Ordered[CltvExpiry]
Companion:
object
Source:
Lightning.scala
object CltvExpiry
Companion:
class
Source:
Lightning.scala
case class CltvExpiryDelta(underlying: Int) extends Ordered[CltvExpiryDelta]
object Crypto

see https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki

case class FeeratePerByte(feerate: Satoshi)

Fee rate in satoshi-per-bytes.

Fee rate in satoshi-per-bytes.

Companion:
object
Source:
Feerates.scala
Companion:
class
Source:
Feerates.scala
case class FeeratePerKB(feerate: Satoshi) extends Ordered[FeeratePerKB]

Fee rate in satoshi-per-kilo-bytes (1 kB = 1000 bytes).

Fee rate in satoshi-per-kilo-bytes (1 kB = 1000 bytes).

Companion:
object
Source:
Feerates.scala
Companion:
class
Source:
Feerates.scala
case class FeeratePerKw(feerate: Satoshi) extends Ordered[FeeratePerKw]

Fee rate in satoshi-per-kilo-weight.

Fee rate in satoshi-per-kilo-weight.

Companion:
object
Source:
Feerates.scala
Companion:
class
Source:
Feerates.scala
case class FeeratesPerKB(mempoolMinFee: FeeratePerKB, block_1: FeeratePerKB, blocks_2: FeeratePerKB, blocks_6: FeeratePerKB, blocks_12: FeeratePerKB, blocks_36: FeeratePerKB, blocks_72: FeeratePerKB, blocks_144: FeeratePerKB, blocks_1008: FeeratePerKB)

Fee rates in satoshi-per-kilo-bytes (1 kb = 1000 bytes). The mempoolMinFee is the minimal fee required for a tx to enter the mempool (and then be relayed to other nodes and eventually get confirmed). If our fee provider doesn't expose this data, using its biggest block target should be a good enough estimation.

Fee rates in satoshi-per-kilo-bytes (1 kb = 1000 bytes). The mempoolMinFee is the minimal fee required for a tx to enter the mempool (and then be relayed to other nodes and eventually get confirmed). If our fee provider doesn't expose this data, using its biggest block target should be a good enough estimation.

Source:
Feerates.scala
case class FeeratesPerKw(mempoolMinFee: FeeratePerKw, block_1: FeeratePerKw, blocks_2: FeeratePerKw, blocks_6: FeeratePerKw, blocks_12: FeeratePerKw, blocks_36: FeeratePerKw, blocks_72: FeeratePerKw, blocks_144: FeeratePerKw, blocks_1008: FeeratePerKw)

Fee rates in satoshi-per-kilo-weight (1 kw = 1000 weight units).

Fee rates in satoshi-per-kilo-weight (1 kw = 1000 weight units).

Companion:
object
Source:
Feerates.scala
Companion:
class
Source:
Feerates.scala
Companion:
class
Source:
Protocol.scala
case class Getblocks(version: Long, locatorHashes: Seq[ByteVector], stopHash: ByteVector) extends BtcSerializable[Getblocks]
Companion:
object
Source:
Protocol.scala
object Getdata extends BtcSerializer[Getdata]
Companion:
class
Source:
Protocol.scala
case class Getdata(inventory: Seq[InventoryVector]) extends BtcSerializable[Getdata]
Companion:
object
Source:
Protocol.scala
Companion:
class
Source:
Protocol.scala
case class Getheaders(version: Long, locatorHashes: Seq[ByteVector], stopHash: ByteVector) extends BtcSerializable[Getheaders]
Companion:
object
Source:
Protocol.scala
object Headers extends BtcSerializer[Headers]
Companion:
class
Source:
Protocol.scala
case class Headers(headers: Seq[BlockHeader]) extends BtcSerializable[Headers]
Companion:
object
Source:
Protocol.scala
Companion:
class
Source:
Protocol.scala
case class Inventory(inventory: Seq[InventoryVector]) extends BtcSerializable[Inventory]
Companion:
object
Source:
Protocol.scala
case class InventoryVector(`type`: Long, hash: ByteVector) extends BtcSerializable[InventoryVector]
Companion:
object
Source:
Protocol.scala

Lexicographical Ordering of Transaction Inputs and Outputs see https://github.com/bitcoin/bips/blob/master/bip-0069.mediawiki

Lexicographical Ordering of Transaction Inputs and Outputs see https://github.com/bitcoin/bips/blob/master/bip-0069.mediawiki

Source:
LexicographicalOrdering.scala
case class MerkleBlock(version: Long, previousBlockHash: ByteVector, merkleRoot: ByteVector, timestamp: Long, bits: Long, nonce: Long, txCount: Int, hashes: Seq[ByteVector], flags: ByteVector) extends BtcSerializable[MerkleBlock]
Value parameters:
bits

The calculated difficulty target being used for this block

flags

flag bits, packed per 8 in a byte, least significant bit first (including standard varint size prefix)

hashes

hashes in depth-first order (including standard varint size prefix)

merkleRoot

The reference to a Merkle tree collection which is a hash of all transactions related to this block

nonce

The nonce used to generate this block… to allow variations of the header and compute different hashes

previousBlockHash

The hash value of the previous block this particular block references

timestamp

A timestamp recording when this block was created (Limited to 2106!)

txCount

Number of transactions in the block (including unmatched ones)

version

Block version information, based upon the software version creating this block

Companion:
object
Source:
MerkleBlock.scala
object MerkleTree

see https://en.bitcoin.it/wiki/Protocol_specification#Merkle_Trees

object Message extends BtcSerializer[Message]
Companion:
class
Source:
Protocol.scala
case class Message(magic: Long, command: String, payload: ByteVector) extends BtcSerializable[Message]

Bitcoin message exchanged by nodes over the network

Bitcoin message exchanged by nodes over the network

Value parameters:
command

ASCII string identifying the packet content, NULL padded (non-NULL padding results in packet rejected)

magic

Magic value indicating message origin network, and used to seek to next message when stream state is unknown

payload

The actual data

Companion:
object
Source:
Protocol.scala
case class MilliSatoshi(underlying: Long) extends BtcAmount with Ordered[MilliSatoshi]

see https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki

case class NetworkAddress(services: Long, address: InetAddress, port: Long) extends BtcSerializable[NetworkAddress]
Companion:
object
Source:
Protocol.scala
case class NetworkAddressWithTimestamp(time: Long, services: Long, address: InetAddress, port: Long) extends BtcSerializable[NetworkAddressWithTimestamp]
Companion:
object
Source:
Protocol.scala
case object OP_0 extends ScriptElt
case object OP_0NOTEQUAL extends ScriptElt
case object OP_1 extends ScriptElt
case object OP_10 extends ScriptElt
case object OP_11 extends ScriptElt
case object OP_12 extends ScriptElt
case object OP_13 extends ScriptElt
case object OP_14 extends ScriptElt
case object OP_15 extends ScriptElt
case object OP_16 extends ScriptElt
case object OP_1ADD extends ScriptElt
case object OP_1NEGATE extends ScriptElt
case object OP_1SUB extends ScriptElt
case object OP_2 extends ScriptElt
case object OP_2DIV extends ScriptElt
case object OP_2DROP extends ScriptElt
case object OP_2DUP extends ScriptElt
case object OP_2MUL extends ScriptElt
case object OP_2OVER extends ScriptElt
case object OP_2ROT extends ScriptElt
case object OP_2SWAP extends ScriptElt
case object OP_3 extends ScriptElt
case object OP_3DUP extends ScriptElt
case object OP_4 extends ScriptElt
case object OP_5 extends ScriptElt
case object OP_6 extends ScriptElt
case object OP_7 extends ScriptElt
case object OP_8 extends ScriptElt
case object OP_9 extends ScriptElt
case object OP_ABS extends ScriptElt
case object OP_ADD extends ScriptElt
case object OP_AND extends ScriptElt
case object OP_BOOLAND extends ScriptElt
case object OP_BOOLOR extends ScriptElt
case object OP_CAT extends ScriptElt
case object OP_CHECKMULTISIG extends ScriptElt
case object OP_CHECKSIG extends ScriptElt
case object OP_CHECKSIGVERIFY extends ScriptElt
case object OP_CODESEPARATOR extends ScriptElt
case object OP_DEPTH extends ScriptElt
case object OP_DIV extends ScriptElt
case object OP_DROP extends ScriptElt
case object OP_DUP extends ScriptElt
case object OP_ELSE extends ScriptElt
case object OP_ENDIF extends ScriptElt
case object OP_EQUAL extends ScriptElt
case object OP_EQUALVERIFY extends ScriptElt
case object OP_FROMALTSTACK extends ScriptElt
case object OP_GREATERTHAN extends ScriptElt
case object OP_HASH160 extends ScriptElt
case object OP_HASH256 extends ScriptElt
case object OP_IF extends ScriptElt
case object OP_IFDUP extends ScriptElt
case class OP_INVALID(code: Int) extends ScriptElt
case object OP_INVALIDOPCODE extends ScriptElt
case object OP_INVERT extends ScriptElt
case object OP_LEFT extends ScriptElt
case object OP_LESSTHAN extends ScriptElt
case object OP_LESSTHANOREQUAL extends ScriptElt
case object OP_LSHIFT extends ScriptElt
case object OP_MAX extends ScriptElt
case object OP_MIN extends ScriptElt
case object OP_MOD extends ScriptElt
case object OP_MUL extends ScriptElt
case object OP_NEGATE extends ScriptElt
case object OP_NIP extends ScriptElt
case object OP_NOP extends ScriptElt
case object OP_NOP1 extends ScriptElt
case object OP_NOP10 extends ScriptElt
case object OP_NOP4 extends ScriptElt
case object OP_NOP5 extends ScriptElt
case object OP_NOP6 extends ScriptElt
case object OP_NOP7 extends ScriptElt
case object OP_NOP8 extends ScriptElt
case object OP_NOP9 extends ScriptElt
case object OP_NOT extends ScriptElt
case object OP_NOTIF extends ScriptElt
case object OP_NUMEQUAL extends ScriptElt
case object OP_NUMEQUALVERIFY extends ScriptElt
case object OP_NUMNOTEQUAL extends ScriptElt
case object OP_OR extends ScriptElt
case object OP_OVER extends ScriptElt
case object OP_PICK extends ScriptElt
Companion:
class
Source:
ScriptElt.scala
case class OP_PUSHDATA(data: ByteVector, code: Int) extends ScriptElt
Companion:
object
Source:
ScriptElt.scala
case object OP_PUSHDATA1 extends ScriptElt
case object OP_PUSHDATA2 extends ScriptElt
case object OP_PUSHDATA4 extends ScriptElt
case object OP_RESERVED extends ScriptElt
case object OP_RESERVED1 extends ScriptElt
case object OP_RESERVED2 extends ScriptElt
case object OP_RETURN extends ScriptElt
case object OP_RIGHT extends ScriptElt
case object OP_RIPEMD160 extends ScriptElt
case object OP_ROLL extends ScriptElt
case object OP_ROT extends ScriptElt
case object OP_RSHIFT extends ScriptElt
case object OP_SHA1 extends ScriptElt
case object OP_SHA256 extends ScriptElt
case object OP_SIZE extends ScriptElt
case object OP_SMALLINTEGER extends ScriptElt
case object OP_SUB extends ScriptElt
case object OP_SUBSTR extends ScriptElt
case object OP_SWAP extends ScriptElt
case object OP_TOALTSTACK extends ScriptElt
case object OP_TUCK extends ScriptElt
case object OP_VER extends ScriptElt
case object OP_VERIF extends ScriptElt
case object OP_VERIFY extends ScriptElt
case object OP_VERNOTIF extends ScriptElt
case object OP_WITHIN extends ScriptElt
case object OP_XOR extends ScriptElt
sealed trait OnionPaymentPayloadTlv extends Tlv

Tlv types used inside a payment onion.

Tlv types used inside a payment onion.

Companion:
object
Source:
PaymentOnion.scala
Companion:
class
Source:
Transaction.scala
case class OutPoint(hash: ByteVector32, index: Long) extends BtcSerializable[OutPoint]

an out point is a reference to a specific output in a specific transaction that we want to claim

an out point is a reference to a specific output in a specific transaction that we want to claim

Value parameters:
hash

reversed sha256(sha256(tx)) where tx is the transaction we want to refer to

index

index of the output in tx that we want to refer to

Companion:
object
Source:
Transaction.scala
case class Psbt(global: Global, inputs: Seq[Input], outputs: Seq[Output])

A partially signed bitcoin transaction: see https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki.

A partially signed bitcoin transaction: see https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki.

Value parameters:
global

global psbt data containing the transaction to be signed.

inputs

signing data for each input of the transaction to be signed (order matches the unsigned tx).

outputs

signing data for each output of the transaction to be signed (order matches the unsigned tx).

Companion:
object
Source:
Psbt.scala
object Psbt

Partially signed bitcoin transactions: see https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki

Partially signed bitcoin transactions: see https://github.com/bitcoin/bips/blob/master/bip-0174.mediawiki

Companion:
class
Source:
Psbt.scala
object Reject extends BtcSerializer[Reject]
Companion:
class
Source:
Protocol.scala
case class Reject(message: String, code: Long, reason: String, data: ByteVector) extends BtcSerializable[Reject]
Companion:
object
Source:
Protocol.scala
case class Satoshi(underlying: Long) extends BtcAmount with Ordered[Satoshi]
final implicit class SatoshiLong(n: Long) extends AnyVal
object Script
abstract class ScriptElt
Companion:
object
Source:
ScriptElt.scala
object ScriptElt
Companion:
class
Source:
ScriptElt.scala

script execution flags

script execution flags

Source:
Script.scala

a script witness is just a stack of data there is one script witness per transaction input

a script witness is just a stack of data there is one script witness per transaction input

Value parameters:
stack

items to be pushed on the stack

Companion:
object
Source:
Transaction.scala
case class ShortChannelId(id: Long) extends Ordered[ShortChannelId]
Companion:
object
Source:
Lightning.scala
Companion:
class
Source:
Lightning.scala
case class TimestampMilli(underlying: Long) extends Ordered[TimestampMilli]
Companion:
object
Source:
Lightning.scala
Companion:
class
Source:
Lightning.scala
case class TimestampSecond(underlying: Long) extends Ordered[TimestampSecond]
Companion:
object
Source:
Lightning.scala
Companion:
class
Source:
Lightning.scala
case class Transaction(version: Long, txIn: Seq[TxIn], txOut: Seq[TxOut], lockTime: Long) extends BtcSerializable[Transaction]

Transaction

Transaction

Value parameters:
lockTime

The block number or timestamp at which this transaction is locked

txIn

Transaction inputs

txOut

Transaction outputs

version

Transaction data format version

Companion:
object
Source:
Transaction.scala
case class TxCoordinates(blockHeight: BlockHeight, txIndex: Int, outputIndex: Int)
object TxIn extends BtcSerializer[TxIn]
Companion:
class
Source:
Transaction.scala
case class TxIn(outPoint: OutPoint, signatureScript: ByteVector, sequence: Long, witness: ScriptWitness) extends BtcSerializable[TxIn]

Transaction input

Transaction input

Value parameters:
outPoint

Previous output transaction reference

sequence

Transaction version as defined by the sender. Intended for "replacement" of transactions when information is updated before inclusion into a block. Repurposed for OP_CSV (see BIPs 68 & 112)

signatureScript

Signature script which should match the public key script of the output that we want to spend

witness

Transaction witness (i.e. what is in sig script for standard transactions).

Companion:
object
Source:
Transaction.scala
object TxOut extends BtcSerializer[TxOut]
Companion:
class
Source:
Transaction.scala
case class TxOut(amount: Satoshi, publicKeyScript: ByteVector) extends BtcSerializable[TxOut]

Transaction output

Transaction output

Value parameters:
amount

amount in Satoshis

publicKeyScript

public key script which sets the conditions for spending this output

Companion:
object
Source:
Transaction.scala
case class UInt64(underlying: Long) extends Ordered[UInt64]
Companion:
object
Source:
UInt64.scala
object UInt64
Companion:
class
Source:
UInt64.scala
object Version extends BtcSerializer[Version]
Companion:
class
Source:
Protocol.scala
case class Version(version: Long, services: Long, timestamp: Long, addr_recv: NetworkAddress, addr_from: NetworkAddress, nonce: Long, user_agent: String, start_height: Long, relay: Boolean) extends BtcSerializable[Version]
Value parameters:
addr_from

The network address of the node emitting this message

addr_recv

The network address of the node receiving this message

nonce

Node random nonce, randomly generated every time a version packet is sent. This nonce is used to detect connections to self.

relay

Whether the remote peer should announce relayed transactions or not, see BIP 0037, since version >= 70001

services

bitfield of features to be enabled for this connection

start_height

The last block received by the emitting node

timestamp

standard UNIX timestamp in seconds

user_agent

User Agent

version

Identifies protocol version being used by the node

Companion:
object
Source:
Protocol.scala

Value members

Concrete methods

Value parameters:
chainHash

chain hash (i.e. hash of the genesis block of the chain we're on)

pub

public key

Returns:

the p2swh-of-p2pkh address for this key). It is a Base58 address that is compatible with most bitcoin wallets

Source:
package.scala
Value parameters:
chainHash

chain hash (i.e. hash of the genesis block of the chain we're on)

pub

public key

Returns:

the BIP84 address for this key (i.e. the p2wpkh address for this key). It is a Bech32 address that will be understood only by native sewgit wallets

Source:
package.scala
Value parameters:
chainHash

hash of the chain (i.e. hash of the genesis block of the chain we're on)

script

public key script

Returns:

the address of this public key script on this chain

Source:
package.scala
Value parameters:
chainHash

hash of the chain (i.e. hash of the genesis block of the chain we're on)

script

public key script

Returns:

the address of this public key script on this chain

Source:
package.scala
def decodeCompact(input: Long): (BigInteger, Boolean, Boolean)
Value parameters:
input

compact size encoded integer as used to encode proof-of-work difficulty target

Returns:

a (result, isNegative, overflow) tuple were result is the decoded integer

Source:
package.scala
def encodeCompact(value: BigInteger): Long
Value parameters:
value

input value

Returns:

the compact encoding of the input value. this is used to encode proof-of-work target into the bits block header field

Source:
package.scala
def isAnyoneCanPay(sighashType: Int): Boolean
def isHashNone(sighashType: Int): Boolean
def isHashSingle(sighashType: Int): Boolean

Concrete fields

signature hash flags

signature hash flags

Source:
package.scala

Implicits

Implicits

final implicit def BtcDouble(n: Double): BtcDouble
final implicit def SatoshiLong(n: Long): SatoshiLong
implicit def btc2millisatoshi(input: Btc): MilliSatoshi
implicit def btc2satoshi(input: Btc): Satoshi
implicit def millisatoshi2btc(input: MilliSatoshi): Btc
implicit def satoshi2btc(input: Satoshi): Btc