Skip to content

Instantly share code, notes, and snippets.

View HAOYUatHZ's full-sized avatar
😈
POISONed

HAOYUatHZ HAOYUatHZ

😈
POISONed
View GitHub Profile

升级版比原借贷合约

在双方(“借款人”和“贷款人”)之间创建债务协议,其中抵押品锁定在P2SH中,并且只能在借款人偿还债务协议中的本金和利息 (资产 A) 后才能使用。在借款人不还款的情况下,借款人或贷款人可以选择清算抵押品 (资产 B) ,这将涉及抵押品与贷款货币的原子交换。如果双方中至少有一方不选择清算,那么当资金最初锁定在P2SH时,各方将有权获得一定比例的抵押品。

这些资金被锁定在两个脚本中。可退还抵押品和可扣押抵押品脚本。发送给这些脚本的资金代表了在还款失败且各方不选择清算的情况下各方有权获得的抵押品的百分比。

定义

借款人:在借款人的借款请求获得批准后,将抵押品 (资产 B) 锁定并从贷款人收到 (资产 A) 贷款资金的人

# install gogoprotobuf
# install protobuf-compiler
protoc -I=. -I=$GOPATH/src -I=$GOPATH/src/github.com/gogo/protobuf/protobuf --gogofaster_out=plugins=grpc:. *.proto
USE vapor;
ALTER TABLE assets ADD COLUMN total_supply varchar(32) DEFAULT '0' AFTER btc_price;
SELECT asset_id, SUM(amount) FROM utxos WHERE is_spend = false GROUP BY asset_id;
UPDATE assets SET total_supply = ??? WHERE id = ???;
@HAOYUatHZ
HAOYUatHZ / checkOutput.md
Last active August 1, 2019 02:32
checkOutput
  1. https://github.com/Bytom/bytom/blob/master/protocol/vm/ops.go#L311 映射到函数
OP_CHECKOUTPUT: {OP_CHECKOUTPUT, "CHECKOUTPUT", opCheckOutput},
  1. https://github.com/Bytom/bytom/blob/master/protocol/vm/introspection.go#L3-L48 弹栈做检验
  2. https://github.com/Bytom/bytom/blob/master/protocol/validation/vmcontext.go#L106
cd $GOPATH/src/github.com/golang/protobuf/
git checkout 572071c
go install github.com/golang/protobuf/protoc-gen-go
cd $GOPATH/src/github.com/bytom/protocol/bc/
protoc --go_out=. *.proto
@HAOYUatHZ
HAOYUatHZ / tx count
Last active January 17, 2019 10:50
tx count
mysql> SELECT COUNT(*) FROM blockcenter.address_transactions where address_id = 3;
+----------+
| COUNT(*) |
+----------+
| 38283 |
+----------+
1 row in set (0.02 sec)
@HAOYUatHZ
HAOYUatHZ / main.go
Created January 15, 2019 02:46
test gorm association
package main
import (
"fmt"
// "github.com/jinzhu/gorm"
log "github.com/sirupsen/logrus"
"github.com/blockcenter/config"
"github.com/blockcenter/database"
# grep -o -E 'MinerName=.* +diff=[0-9]+' copy.log > all_stats.log
filename = "all_stats.log"
all_earn = 453.259264136
from collections import defaultdict
d = {}
d = defaultdict(lambda: 0, d)
#!/bin/bash
ps -ef | grep 'sipe' | grep -v 'grep' | grep -v 'restart_sipe'
if [ $? -eq 0 ];then
kill -9 `ps -ef | grep 'sipe' | grep -v 'grep'| grep -v 'kill' | awk '{print $2}'`
else
echo 'Fail to find sipe process'
fi
mkdir -p $HOME/log/sipe/
current=`date +%Y%m%d%H%M%S`
targetHex := job.Target
decoded, _ := hex.DecodeString(targetHex)
decoded = reverse(decoded)
target_int := new(big.Int).SetBytes(padded)
max_bits_int := 1*(2^55-1)*256^((2^8-1)-3)