Documentation
¶
Index ¶
- Constants
- Variables
- type AddHtlcRequestInfo
- type AtomicSwapAcceptedInfo
- type AtomicSwapInfo
- type BRType
- type BreachRemedyTransaction
- type ChannelInfo
- type ChannelState
- type CloseChannel
- type CommitmentTransaction
- type CommitmentTransactionType
- type CommitmentTxRequestInfo
- type DemoChannelInfo
- type FundingBtcRequest
- type FundingTransaction
- type FundingTransactionState
- type HTLCBreachRemedyTransaction
- type HTLCCommitmentTransaction
- type HTLCExecutionDeliveryOfR
- type HTLCTimeoutBreachRemedyTransaction
- type HTLCTimeoutDeliveryTxB
- type HTLCTimeoutTxForAAndExecutionForB
- type HtlcLockTxByH
- type HtlcPathInfo
- type HtlcPathInfoState
- type HtlcRAndHInfo
- type HtlcRequestCloseCurrTxInfo
- type MinerFeeRedeemTransaction
- type NormalState
- type RDTxWaitingSend
- type RevocableDeliveryTransaction
- type TxInfoState
- type User
- type UserLoginLog
Constants ¶
View Source
const ( CommitmentTransactionType_Rsmc = 0 CommitmentTransactionType_Htlc = 1 )
Variables ¶
View Source
var DBService = dbManager{ Db: nil, }
Functions ¶
This section is empty.
Types ¶
type AddHtlcRequestInfo ¶
type AddHtlcRequestInfo struct {
Id int `storm:"id,increment" json:"id" `
ChannelId string `json:"channel_id"`
RecipientUserPeerId string `json:"recipient_user_peer_id"`
PropertyId int64 `json:"property_id"`
Amount float64 `json:"amount"`
Memo string `json:"memo"`
H string `json:"h"`
HtlcChannelPath string `json:"htlc_channel_path"`
LastTempAddressPrivateKey string `json:"last_temp_address_private_key"` // 支付方的上一个RSMC委托交易用到的临时地址的私钥 存储在bob这边的请求
CurrRsmcTempAddressPubKey string `json:"curr_rsmc_temp_address_pub_key"` // 创建Cnx中的toRsmc的部分使用的临时地址的公钥
CurrHtlcTempAddressPubKey string `json:"curr_htlc_temp_address_pub_key"` // 创建Cnx中的toHtlc的部分使用的临时地址的公钥
CurrHtlcTempAddressForHt1aPubKey string `json:"curr_htlc_temp_address_for_ht1a_pub_key"` // 创建Ht1a中生成ht1a的输出的Rmsc的临时地址的公钥
CurrState NormalState `json:"curr_state"`
CreateBy string `json:"create_by"`
CreateAt time.Time `json:"create_at"`
FinishAt time.Time `json:"finish_at"`
}
type AtomicSwapAcceptedInfo ¶
type AtomicSwapInfo ¶
type BreachRemedyTransaction ¶
type BreachRemedyTransaction struct {
Id int `storm:"id,increment" json:"id" `
CommitmentTxId int `json:"commitment_tx_id"` // parent commitmentTx id
PeerIdA string `json:"peer_id_a"`
PeerIdB string `json:"peer_id_b"`
ChannelId string `json:"channel_id"`
PropertyId int64 `json:"property_id"`
TempPubKey string `json:"temp_pub_key"`
InputAddress string `json:"input_address"`
InputAddressScriptPubKey string `json:"input_address_script_pub_key"`
InputTxHex string `json:"input_tx_hex"`
InputTxid string `json:"input_txid"` //input txid from commitTx alice2&bob multtAddr, so need sign of alice2 and bob
InputVout uint32 `json:"input_vout"` // input vout
InputAmount float64 `json:"input_amount"` //input amount
OutAddress string `json:"out_address"`
Amount float64 `json:"amount"` // output bob amount
BrTxHex string `json:"br_tx_hex"` // first alice2 sign
Txid string `json:"txid"`
Type BRType `json:"type"` //:0:rmsc ,1:htlc,2:ht1a 3:hebr1b
CurrState TxInfoState `json:"curr_state"`
CreateBy string `json:"create_by"`
CreateAt time.Time `json:"create_at"`
SignAt time.Time `json:"sign_at"`
SendAt time.Time `json:"send_at"`
LastEditTime time.Time `json:"last_edit_time"`
Owner string `json:"owner"`
}
to punish alice do not admit the latest commitment tx
type ChannelInfo ¶
type ChannelInfo struct {
bean.OpenChannelInfo
Id int `storm:"id,increment" json:"id"`
ChannelId string `json:"channel_id"`
PeerIdA string `storm:"index" json:"peer_id_a"`
PubKeyA string `json:"pub_key_a"`
AddressA string `json:"address_a"`
PeerIdB string `storm:"index" json:"peer_id_b"`
PubKeyB string `json:"pub_key_b"`
AddressB string `json:"address_b"`
ChannelAddress string `json:"channel_address"`
ChannelAddressRedeemScript string `json:"channel_address_redeem_script"`
ChannelAddressScriptPubKey string `json:"channel_address_script_pub_key"`
PropertyId int64 `json:"property_id"`
CurrState ChannelState `json:"curr_state"`
CreateBy string `json:"create_by"`
CreateAt time.Time `json:"create_at"`
AcceptAt time.Time `json:"accept_at"`
CloseAt time.Time `json:"close_at"`
}
type ChannelState ¶
type ChannelState int
const ( ChannelState_Create ChannelState = 10 ChannelState_WaitFundAsset ChannelState = 11 ChannelState_CanUse ChannelState = 20 ChannelState_Close ChannelState = 21 ChannelState_HtlcTx ChannelState = 22 ChannelState_OpenChannelDefuse ChannelState = 30 ChannelState_FundingDefuse ChannelState = 31 )
type CloseChannel ¶
type CloseChannel struct {
bean.CloseChannel
Id int `storm:"id,increment" json:"id"`
CommitmentTxId int `json:"commitment_tx_id"`
RequestHex string `json:"request_hex"`
Owner string `json:"owner"`
Approval bool `json:"approval"`
CurrState int `json:"curr_state"` // 0: create 1 finish
CreateAt time.Time `json:"create_at"`
}
type CommitmentTransaction ¶
type CommitmentTransaction struct {
Id int `storm:"id,increment" json:"id" `
LastCommitmentTxId int `json:"last_commitment_tx_id"`
LastHash string `json:"last_hash"`
CurrHash string `json:"curr_hash"`
PeerIdA string `json:"peer_id_a"`
PeerIdB string `json:"peer_id_b"`
ChannelId string `json:"channel_id"`
PropertyId int64 `json:"property_id"`
InputTxid string `json:"input_txid"` //input txid from channelAddr: alice&bob multiAddr, so need sign of alice and bob
InputVout uint32 `json:"input_vout"` // input vout
InputAmount float64 `json:"input_amount"` //input amount
TxType CommitmentTransactionType `json:"tx_type"` // 0 rsmc 1 htlc
//RSMC
RSMCTempAddressPubKey string `json:"rsmc_temp_address_pub_key"` //aliceTempRemc or bobTempRsmc
RSMCMultiAddress string `json:"rsmc_multi_address"` //output aliceTempRsmc&bob or alice&bobTempRsmc multiAddr
RSMCRedeemScript string `json:"rsmc_redeem_script"`
RSMCMultiAddressScriptPubKey string `json:"rsmc_multi_address_script_pub_key"`
AmountToRSMC float64 `json:"amount_to_rsmc"` // amount to multiAddr
RsmcInputTxid string `json:"rsmc_input_txid"`
RSMCTxHex string `json:"rsmc_tx_hex"`
RSMCTxid string `json:"rsmc_txid"`
//To CounterParty
ToCounterpartyTxHex string `json:"to_counterparty_tx_hex"`
ToCounterpartyTxid string `json:"to_counterparty_txid"`
AmountToCounterparty float64 `json:"amount_to_counterparty"` //amount to bob(if Cna) or alice(if Cnb)
FromCounterpartySideForMeTxHex string `json:"from_counterparty_side_for_me_tx_hex"` //对方给自己的转账部分,防止对方不广播此交易
//htlc
HtlcChannelPath string `json:"htlc_channel_path"` //借道Path
BeginBlockHeight int `json:"begin_block_height"` //借道时的区块高度
HTLCTempAddressPubKey string `json:"htlc_temp_address_pub_key"` //alice for htlc or bob for htlc
HTLCMultiAddress string `json:"htlc_multi_address"` //output aliceTempHtlc&bob or alice&bobTempHtlc multiAddr
HTLCRedeemScript string `json:"htlc_redeem_script"`
HTLCMultiAddressScriptPubKey string `json:"htlc_multi_address_script_pub_key"`
AmountToHtlc float64 `json:"amount_to_htlc"`
HtlcTxHex string `json:"htlc_tx_hex"`
HTLCTxid string `json:"htlc_txid"`
HtlcH string `json:"htlc_h"`
HtlcR string `json:"htlc_r"`
HtlcSender string `json:"htlc_sender"`
CurrState TxInfoState `json:"curr_state"`
CreateBy string `json:"create_by"`
CreateAt time.Time `json:"create_at"`
SignAt time.Time `json:"sign_at"`
SendAt time.Time `json:"send_at"`
LastEditTime time.Time `json:"last_edit_time"`
Owner string `json:"owner"`
}
CommitmentTransaction
type CommitmentTransactionType ¶
type CommitmentTransactionType int
type CommitmentTxRequestInfo ¶
type DemoChannelInfo ¶
type FundingBtcRequest ¶
type FundingBtcRequest struct {
Id int `storm:"id,increment" json:"id" `
Owner string `json:"owner"`
TemporaryChannelId string `json:"temporary_channel_id"`
TxHash string `json:"tx_hash"`
RedeemHex string `json:"redeem_hex"`
TxId string `json:"tx_id"`
Amount float64 `json:"amount"`
CreateAt time.Time `json:"create_at"`
SignAt time.Time `json:"sign_at"`
SignApproval bool `json:"sign_approval"`
FinishAt time.Time `json:"finish_at"`
IsFinish bool `json:"is_finish"`
}
type FundingTransaction ¶
type FundingTransaction struct {
Id int `storm:"id,increment" json:"id"`
ChannelInfoId int `json:"channel_info_id"`
CurrState FundingTransactionState `json:"curr_state"`
PeerIdA string `json:"peer_id_a"`
PeerIdB string `json:"peer_id_b"`
ChannelId string `json:"channel_id"`
PropertyId int64 `json:"property_id"`
AmountA float64 `json:"amount_a"`
FunderPubKey2ForCommitment string `json:"funder_pub_key_2_for_commitment"`
FundingTxHex string `json:"funding_tx_hex"`
FundingTxid string `json:"funding_txid"`
FundingOutputIndex uint32 `json:"funding_output_index"`
AmountB float64 `json:"amount_b"`
RsmcTempAddressPubKey string `json:"rsmc_temp_address_pub_key"` //为bob准备的
FunderRsmcHex string `json:"funder_rsmc_hex"`
CreateBy string `json:"create_by"`
Owner string `json:"owner"`
FunderAddress string `json:"funder_address"`
CreateAt time.Time `json:"create_at"`
FundeeSignAt time.Time `json:"fundee_sign_at"`
}
type FundingTransactionState ¶
type FundingTransactionState int
const ( FundingTransactionState_Create FundingTransactionState = 10 FundingTransactionState_Accept FundingTransactionState = 20 FundingTransactionState_Defuse FundingTransactionState = 30 )
type HTLCBreachRemedyTransaction ¶
type HTLCBreachRemedyTransaction BreachRemedyTransaction
to punish alice do not admit the latest commitment tx
type HTLCCommitmentTransaction ¶
type HTLCCommitmentTransaction CommitmentTransaction
type HTLCExecutionDeliveryOfR ¶
type HTLCExecutionDeliveryOfR struct {
Id int `storm:"id,increment" json:"id" `
ChannelId string `json:"channel_id"`
CommitmentTxId int `json:"commitment_tx_id"`
HLockTxId int `json:"hlock_tx_id"`
InputHex string `json:"input_hex"`
InputTxid string `json:"input_txid"` // input txid from commitTx aliceTempHtlc&bob multtaddr, so need sign of aliceTempHtlc and bob
InputAmount float64 `json:"input_amount"` // input amount
HtlcR string `json:"htlc_r"`
OutputAddress string `json:"output_address"` //to Bob
OutAmount float64 `json:"out_amount"`
TxHex string `json:"tx_hex"`
Txid string `json:"txid"`
CurrState TxInfoState `json:"curr_state"`
Owner string `json:"owner"`
IsEnable bool `json:"is_enable"`
CreateAt time.Time `json:"create_at"`
SendAt time.Time `json:"send_at"`
CreateBy string `json:"create_by"`
}
HED1a when get R 如果bob返回了正确的R,就可以完成签名,标识这次的htlc可以成功了
type HTLCTimeoutBreachRemedyTransaction ¶
type HTLCTimeoutBreachRemedyTransaction struct {
Id int `storm:"id,increment" json:"id" `
ChannelId string `json:"channel_id"`
CommitmentTxId int `json:"commitment_tx_id"` // parent commitmentTx id
HTLCTimeoutTxForAAndExecutionForBId int `json:"htlc_timeout_tx_for_a_and_execution_for_b_id"`
PropertyId int64 `json:"property_id"`
InputHex string `json:"input_hex"`
Amount float64 `json:"amount"` // output bob amount
TxHex string `json:"tx_hex"`
Txid string `json:"txid"`
CurrState TxInfoState `json:"curr_state"`
CreateBy string `json:"create_by"`
CreateAt time.Time `json:"create_at"`
SignAt time.Time `json:"sign_at"`
SendAt time.Time `json:"send_at"`
LastEditTime time.Time `json:"last_edit_time"`
Owner string `json:"owner"`
}
type HTLCTimeoutDeliveryTxB ¶
type HTLCTimeoutDeliveryTxB struct {
Id int `storm:"id,increment" json:"id" `
ChannelId string `json:"channel_id"`
CommitmentTxId int `json:"commitment_tx_id"`
PropertyId int64 `json:"property_id"`
InputHex string `json:"input_hex"`
Timeout int `json:"timeout"`
InputAmount float64 `json:"input_amount"` //input amount
OutputAddress string `json:"output_address"` //output Sender Alice(if alice is sender) or Bob(if bob is sender)
OutAmount float64 `json:"out_amount"`
TxHex string `json:"tx_hex"`
Txid string `json:"txid"`
Owner string `json:"owner"`
CurrState TxInfoState `json:"curr_state"`
CreateAt time.Time `json:"create_at"`
SendAt time.Time `json:"send_at"`
CreateBy string `json:"create_by"`
}
HTD1b 锁住发起方的交易资金:如果bob广播了,如果过了三天,如果R没有获取到,alice可以通过广播拿回资金
type HTLCTimeoutTxForAAndExecutionForB ¶
type HTLCTimeoutTxForAAndExecutionForB struct {
Id int `storm:"id,increment" json:"id" `
ChannelId string `json:"channel_id"`
CommitmentTxId int `json:"commitment_tx_id"`
PropertyId int64 `json:"property_id"`
InputTxid string `json:"input_txid"` // input txid from commitTx aliceTempHtlc&bob multtaddr, so need sign of aliceTempHtlc and bob
InputAmount float64 `json:"input_amount"` // input amount
InputHex string `json:"input_hex"`
Timeout int `json:"timeout"` // if 3days 432=3*24*6
RSMCTempAddressPubKey string `json:"rsmc_temp_address_pub_key"`
RSMCMultiAddress string `json:"rsmc_multi_address"`
RSMCRedeemScript string `json:"rsmc_redeem_script"`
RSMCMultiAddressScriptPubKey string `json:"rsmc_multi_address_script_pub_key"`
RSMCOutAmount float64 `json:"rsmc_out_amount"`
RSMCTxHex string `json:"rsmc_tx_hex"`
RSMCTxid string `json:"rsmc_txid"`
CurrState TxInfoState `json:"curr_state"`
Owner string `json:"owner"`
CreateBy string `json:"create_by"`
CreateAt time.Time `json:"create_at"`
SignAt time.Time `json:"sign_at"`
SendAt time.Time `json:"send_at"`
}
HT1a 锁住发起方的交易资金:锁住的意思是:把资金放到一个临时多签帐号(alice1&bob) HE1b 等获取到R后,锁住接收方的交易资金:锁住的意思是:把资金放到一个临时多签帐号(alice&bob6)
type HtlcLockTxByH ¶
type HtlcLockTxByH struct {
Id int `storm:"id,increment" json:"id" `
ChannelId string `json:"channel_id"`
PropertyId int64 `json:"property_id"`
CommitmentTxId int `json:"commitment_tx_id"`
InputHex string `json:"input_hex"`
InputTxid string `json:"input_txid"` // input txid from commitTx aliceTempHtlc&bob multtaddr, so need sign of aliceTempHtlc and bob
InputVout uint32 `json:"input_vout"` // input vout
InputAmount float64 `json:"input_amount"` // input amount
HtlcH string `json:"htlc_h"` // H(公钥,双签地址之一)
PayeeChannelPubKey string `json:"payee_channel_pub_key"`
OutputAddress string `json:"output_address"` // 双签地址 锁定支付资金
RedeemScript string `json:"redeem_script"` // 双签地址对应的赎回脚本
ScriptPubKey string `json:"script_pub_key"`
OutAmount float64 `json:"out_amount"`
Timeout int `json:"timeout"`
TxHex string `json:"tx_hex"`
Txid string `json:"txid"`
CurrState TxInfoState `json:"curr_state"`
Owner string `json:"owner"`
CreateAt time.Time `json:"create_at"`
SendAt time.Time `json:"send_at"`
CreateBy string `json:"create_by"`
}
HED1a when get H , alice 得到H(公钥),生成三签地址,锁住给中间节点的钱,当得到R(私钥)的时候,完成三签地址的签名,生成最终支付交易
type HtlcPathInfo ¶
type HtlcPathInfo struct {
Id int `storm:"id,increment" json:"id" `
HAndRInfoRequestHash string `json:"h_and_r_info_request_hash"`
H string `json:"h"`
ChannelIdArr []int `json:"channel_id_arr"`
CurrState HtlcPathInfoState `json:"curr_state"`
BeginBlockHeight int `json:"begin_block_height"`
TotalStep int `json:"total_step"`
CurrStep int `json:"curr_step"`
CreateBy string `json:"create_by"`
CreateAt time.Time `json:"create_at"`
CurrRsmcTempPubKey string `json:"curr_rsmc_temp_pub_key"` // for cnb output1 temp data
CurrHtlcTempPubKey string `json:"curr_htlc_temp_pub_key"` // for cnb output2 temp data
//CurrHtlcTempForHe1bOfHPubKey string `json:"curr_htlc_temp_for_he1b_ofh_pub_key"` // temp data when get h for he1b 那个变通交易,用H锁住
CurrHtlcTempForHe1bPubKey string `json:"curr_htlc_temp_for_he1b_pub_key"` // temp data when get r for he1b
}
type HtlcPathInfoState ¶
type HtlcPathInfoState int
const ( HtlcPathInfoState_Created HtlcPathInfoState = 0 HtlcPathInfoState_Forward HtlcPathInfoState = 10 HtlcPathInfoState_Backward HtlcPathInfoState = 11 HtlcPathInfoState_RefusedByInterNode HtlcPathInfoState = -1 )
type HtlcRAndHInfo ¶
type HtlcRAndHInfo struct {
Id int `storm:"id,increment" json:"id" `
SenderPeerId string `json:"sender_peer_id"`
RecipientPeerId string `json:"recipient_peer_id"`
PropertyId int64 `json:"property_id"`
Amount float64 `json:"amount"`
H string `json:"h"`
R string `json:"r"`
RequestHash string `json:"request_hash"`
CurrState NormalState `json:"curr_state"`
CreateBy string `json:"create_by"`
CreateAt time.Time `json:"create_at"`
Memo string `json:"memo"`
}
type HtlcRequestCloseCurrTxInfo ¶
type HtlcRequestCloseCurrTxInfo struct {
Id int `storm:"id,increment" json:"id" `
RequestHash string `json:"request_hash"`
ChannelId string `json:"channel_id"`
CurrRsmcTempAddressPubKey string `json:"curr_rsmc_temp_address_pub_key"`
CreateBy string `json:"create_by"`
CurrState NormalState `json:"curr_state"`
CreateAt time.Time `json:"create_at"`
}
为记录-49的关闭htlc的请求数据
type MinerFeeRedeemTransaction ¶
type MinerFeeRedeemTransaction struct {
Id int `storm:"id,increment" json:"id" `
Owner string `json:"owner"`
TemporaryChannelId string `json:"temporary_channel_id"`
FundingTxId string `json:"funding_tx_id"`
Hex string `json:"hex"`
Txid string `json:"txid"`
CreateAt time.Time `json:"create_at"`
}
redeem the btc fee
type NormalState ¶
type NormalState int
const ( NS_Create NormalState = 10 NS_Finish NormalState = 20 NS_Refuse NormalState = 30 )
type RDTxWaitingSend ¶
type RDTxWaitingSend struct {
Id int `storm:"id,increment" json:"id" `
TransactionHex string `json:"transaction_hex"`
Type int `json:"type"` // 0: RD 1000, 1:HT1a 2:htd1b
HtnxIdAndHtnxRdId []int `json:"htnx_id_and_htnx_rd_id"` // for ht1a later logic
IsEnable bool `json:"is_enable"`
CreateAt time.Time `json:"create_at"`
FinishAt time.Time `json:"finish_at"`
}
rd tx of waiting 1000 sequence
type RevocableDeliveryTransaction ¶
type RevocableDeliveryTransaction struct {
Id int `storm:"id,increment" json:"id" `
CommitmentTxId int `json:"commitment_tx_id"`
PeerIdA string `json:"peer_id_a"`
PeerIdB string `json:"peer_id_b"`
ChannelId string `json:"channel_id"`
PropertyId int64 `json:"property_id"`
InputTxHex string `json:"input_tx_hex"`
InputTxid string `json:"input_txid"` //input txid from commitTx alice2&bob multtaddr, so need sign of alice2 and bob
InputVout uint32 `json:"input_vout"` // input vout
InputAmount float64 `json:"input_amount"` //input amount
OutputAddress string `json:"output_address"` //output alice
Sequence int `json:"sequence"`
RDType int `json:"rd_type"` // default 0 for rsmc Rd,1 for htrd
Amount float64 `json:"amount"` // output alice amount
TxHex string `json:"tx_hex"`
Txid string `json:"txid"`
CurrState TxInfoState `json:"curr_state"`
CreateBy string `json:"create_by"`
CreateAt time.Time `json:"create_at"`
SignAt time.Time `json:"sign_at"`
SendAt time.Time `json:"send_at"`
LastEditTime time.Time `json:"last_edit_time"`
Owner string `json:"owner"`
}
close channel , alice or bob wait 1000 sequence to drawback the balance
type TxInfoState ¶
type TxInfoState int
const ( TxInfoState_Create TxInfoState = 5 TxInfoState_Htlc_WaitHTRD1aSign TxInfoState = 6 //等待bob创建htrd1a TxInfoState_CreateAndSign TxInfoState = 10 TxInfoState_Htlc_GetH TxInfoState = 11 // 创建Htlc交易的时候的状态 TxInfoState_Htlc_GetR TxInfoState = 12 // 获取到R后的状态 TxInfoState_SendHex TxInfoState = 20 TxInfoState_Abord TxInfoState = 30 )
Click to show internal directories.
Click to hide internal directories.