Skip to content

Instantly share code, notes, and snippets.

View matthewjablack's full-sized avatar

Matthew Black matthewjablack

View GitHub Profile
initiator_funding_input: 41 + script_sig_len bytes
	- previous_out_point: 36 bytes
		- hash: 32 bytes
		- index: 4 bytes
	- var_int: 1 byte (script_sig length)
	- script_sig: script_sig_len bytes
	- witness <----	"witness" is stored
 			separately, and the cost for its size is smaller. So,
 		    the calculation of ordinary data is separated

Atmoic Loans Liquid Example

The goal of this is to show how an Atomic Loan can be achieved using Liquid (L-BTC as collateral and elements stablecoin asset such as L-USDT)

Parties involved:

  1. Alice - Lender

  2. Bob - Borrower

diff --git a/packages/core-wallet-state/src/reducers/networks.js b/packages/core-wallet-state/src/reducers/networks.js
index be622680..c83a39b7 100644
--- a/packages/core-wallet-state/src/reducers/networks.js
+++ b/packages/core-wallet-state/src/reducers/networks.js
@@ -2,11 +2,11 @@ import {
UPDATE_CURRENT_NETWORK,
UPDATE_NETWORK_LIST
} from '../actions/networks';
-import { TESTNET } from '../constants/networks';
+import { MAINNET } from '../constants/networks';
diff --git a/packages/core-bitcoin/src/apis/transaction.js b/packages/core-bitcoin/src/apis/transaction.js
index 889a3502..535c0c71 100644
--- a/packages/core-bitcoin/src/apis/transaction.js
+++ b/packages/core-bitcoin/src/apis/transaction.js
@@ -17,15 +17,17 @@ const isValidTxnAmount = (balance, totalAmount) => balance.gt(totalAmount);
export const transfer = async (transaction, network, account) => {
const { to, amount, unit } = transaction;
const { transactionUrl } = network;
- const { balance } = await BalanceAPI.getBalance({
- account,
const config = {
bitcoin: {
rpc: {
host: 'http://localhost:18443',
username: 'bitcoin',
password: 'local321'
},
network: 'bitcoin_regtest',
value: 1000000,
mineBlocks: true
const config = {
bitcoin: {
rpc: {
host: 'http://localhost:18443',
username: 'bitcoin',
password: 'local321'
},
network: 'bitcoin_regtest',
value: 1000000,
mineBlocks: true
pragma solidity ^0.5.10;
/// @title ISPVConsumer
/// @author Summa (https://summa.one)
/// @notice This interface consumes validated transaction information.
/// It is the primary way that user contracts accept
/// @dev Implement this interface to process transactions provided by
/// the Relay system.
interface ISPVConsumer {
/// @notice A consumer for Bitcoin transaction information.
async createManySigs (tx, address, cols, expirations, period) {
const isSegwit = cols[0].paymentVariantName === 'p2wsh' || cols[0].paymentVariantName === 'p2sh_p2wsh'
const { approveExpiration, liquidationExpiration, seizureExpiration } = expirations
let lockTime = 0
if (period === 'seizurePeriod') {
lockTime = liquidationExpiration
} else if (period === 'refundPeriod') {
lockTime = seizureExpiration
Request Loan: https://kovan.etherscan.io/tx/0x093d4854f34647c764f32ded2c9595a018d5d48282ee4e4a9ae5c073b068d451
Lock Collateral: https://blockstream.info/testnet/tx/f4e139634aef6896bd940df4439263f087054532bb49ecf0ff5aaba307d70d02
Withdraw Loan: https://kovan.etherscan.io/tx/0x8de4def0b81e5cc27a9be71b5b6e7716916200c45befb8fca59ec0953c5c26d7
ERC20 Approve: https://kovan.etherscan.io/tx/0x4046eafad114ee86f2e69b2470fb68fd9962d41cdf073d0925f8757d7a263504
Repay Loan: https://kovan.etherscan.io/tx/0xfa10ea047bb936360b6c19af250777e63c652b3f246e49bddb0d35da6a59f20c
Unlock Collateral: https://blockstream.info/testnet/tx/2585b1b54b30194f2c9d24e2ad6bfec2e44598bbc340d5b26624b29dc92b9635
@matthewjablack
matthewjablack / ERC20Loan.sol
Created November 15, 2018 15:11
TAL ERC20Loan Contract
import './ExampleCoin.sol';
pragma solidity ^0.4.21;
contract ERC20Loan {
uint public principle;
uint public interest;
address public lender;
address public borrower;