Upon further reflection Our/Their seperation makes no sense
This commit is contained in:
parent
b79d0cc65a
commit
0c0900006d
@ -19,14 +19,10 @@ type MicroSatoshi int32
|
|||||||
type CreateChannel struct {
|
type CreateChannel struct {
|
||||||
ChannelType uint8
|
ChannelType uint8
|
||||||
|
|
||||||
OurFundingAmount btcutil.Amount
|
FundingAmount btcutil.Amount
|
||||||
TheirFundingAmount btcutil.Amount
|
ReserveAmount btcutil.Amount
|
||||||
OurReserveAmount btcutil.Amount
|
MinFeePerKb btcutil.Amount
|
||||||
TheirReserveAmount btcutil.Amount
|
|
||||||
OurMinFeePerKb btcutil.Amount
|
|
||||||
TheirMinFeePerKb btcutil.Amount
|
|
||||||
|
|
||||||
//Either party can change.
|
|
||||||
//Should double-check the total funding later
|
//Should double-check the total funding later
|
||||||
MinTotalFundingAmount btcutil.Amount
|
MinTotalFundingAmount btcutil.Amount
|
||||||
|
|
||||||
@ -39,15 +35,11 @@ type CreateChannel struct {
|
|||||||
//2: channel responder
|
//2: channel responder
|
||||||
FeePayer uint8
|
FeePayer uint8
|
||||||
|
|
||||||
OurRevocationHash [20]byte
|
RevocationHash [20]byte
|
||||||
TheirRevocationHash [20]byte
|
Pubkey *btcec.PublicKey
|
||||||
OurPubkey *btcec.PublicKey
|
DeliveryPkScript PkScript //*MUST* be either P2PKH or P2SH
|
||||||
TheirPubkey *btcec.PublicKey
|
|
||||||
OurDeliveryPkScript PkScript //*MUST* be either P2PKH or P2SH
|
|
||||||
TheirDeliveryPkScript PkScript //*MUST* be either P2PKH or P2SH
|
|
||||||
|
|
||||||
OurInputs []*wire.TxIn
|
Inputs []*wire.TxIn
|
||||||
TheirInputs []*wire.TxIn
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Writes the big endian representation of element
|
//Writes the big endian representation of element
|
||||||
@ -263,13 +255,13 @@ func (c *CreateChannel) DeserializeFundingRequest(r *bytes.Buffer) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
//Their Funding Amount
|
// Funding Amount
|
||||||
err = readElement(r, c.TheirFundingAmount)
|
err = readElement(r, c.FundingAmount)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
//Their Channel Minimum Capacity
|
// Channel Minimum Capacity
|
||||||
var theirMinimumFunding btcutil.Amount
|
var theirMinimumFunding btcutil.Amount
|
||||||
err = readElement(r, theirMinimumFunding)
|
err = readElement(r, theirMinimumFunding)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -281,26 +273,26 @@ func (c *CreateChannel) DeserializeFundingRequest(r *bytes.Buffer) error {
|
|||||||
c.MinTotalFundingAmount = theirMinimumFunding
|
c.MinTotalFundingAmount = theirMinimumFunding
|
||||||
}
|
}
|
||||||
|
|
||||||
//Their Revocation Hash
|
// Revocation Hash
|
||||||
err = readElement(r, c.TheirRevocationHash)
|
err = readElement(r, c.RevocationHash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
//Their Commitment Pubkey
|
// Commitment Pubkey
|
||||||
err = readElement(r, c.TheirPubkey)
|
err = readElement(r, c.Pubkey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
//Their Reserve Amount
|
// Reserve Amount
|
||||||
err = readElement(r, c.TheirReserveAmount)
|
err = readElement(r, c.ReserveAmount)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
//Minimum Transaction Fee Per Kb
|
//Minimum Transaction Fee Per Kb
|
||||||
err = readElement(r, c.TheirMinFeePerKb)
|
err = readElement(r, c.MinFeePerKb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -317,14 +309,14 @@ func (c *CreateChannel) DeserializeFundingRequest(r *bytes.Buffer) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
//Their Delivery PkScript
|
// Delivery PkScript
|
||||||
err = readElement(r, c.TheirDeliveryPkScript)
|
err = readElement(r, c.DeliveryPkScript)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
//Create the TxIns
|
//Create the TxIns
|
||||||
err = readElement(r, c.TheirInputs)
|
err = readElement(r, c.Inputs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -350,38 +342,38 @@ func (c *CreateChannel) SerializeFundingRequest(w *bytes.Buffer) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
//Our Funding Amont
|
//Funding Amont
|
||||||
err = writeElement(w, c.OurFundingAmount)
|
err = writeElement(w, c.FundingAmount)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
//Our Channel Minimum Capacity
|
// Channel Minimum Capacity
|
||||||
err = writeElement(w, c.MinTotalFundingAmount)
|
err = writeElement(w, c.MinTotalFundingAmount)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
//Our Revocation Hash
|
// Revocation Hash
|
||||||
err = writeElement(w, c.OurRevocationHash)
|
err = writeElement(w, c.RevocationHash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
//Our Commitment Pubkey
|
// Commitment Pubkey
|
||||||
err = writeElement(w, c.OurPubkey)
|
err = writeElement(w, c.Pubkey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
//Our Reserve Amount
|
// Reserve Amount
|
||||||
err = writeElement(w, c.OurReserveAmount)
|
err = writeElement(w, c.ReserveAmount)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
//Minimum Transaction Fee Per KB
|
//Minimum Transaction Fee Per KB
|
||||||
err = writeElement(w, c.OurMinFeePerKb)
|
err = writeElement(w, c.MinFeePerKb)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -398,9 +390,9 @@ func (c *CreateChannel) SerializeFundingRequest(w *bytes.Buffer) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
//Our Delivery PkScript
|
// Delivery PkScript
|
||||||
//First byte length then pkscript
|
//First byte length then pkscript
|
||||||
err = writeElement(w, c.OurDeliveryPkScript)
|
err = writeElement(w, c.DeliveryPkScript)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -408,7 +400,7 @@ func (c *CreateChannel) SerializeFundingRequest(w *bytes.Buffer) error {
|
|||||||
//Append the actual Txins
|
//Append the actual Txins
|
||||||
//First byte is number of inputs
|
//First byte is number of inputs
|
||||||
//For each input, it's 32bytes txin & 4bytes index
|
//For each input, it's 32bytes txin & 4bytes index
|
||||||
err = writeElement(w, c.OurInputs)
|
err = writeElement(w, c.Inputs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ var (
|
|||||||
ourPubKeyBytes, _ = hex.DecodeString("02f977808cb9577897582d7524b562691e180953dd0008eb44e09594c539d6daee")
|
ourPubKeyBytes, _ = hex.DecodeString("02f977808cb9577897582d7524b562691e180953dd0008eb44e09594c539d6daee")
|
||||||
ourPubKey, _ = btcec.ParsePubKey(ourPubKeyBytes, btcec.S256())
|
ourPubKey, _ = btcec.ParsePubKey(ourPubKeyBytes, btcec.S256())
|
||||||
|
|
||||||
//Our Delivery PkScript
|
// Delivery PkScript
|
||||||
//Privkey: f2c00ead9cbcfec63098dc0a5f152c0165aff40a2ab92feb4e24869a284c32a7
|
//Privkey: f2c00ead9cbcfec63098dc0a5f152c0165aff40a2ab92feb4e24869a284c32a7
|
||||||
//PKhash: n2fkWVphUzw3zSigzPsv9GuDyg9mohzKpz
|
//PKhash: n2fkWVphUzw3zSigzPsv9GuDyg9mohzKpz
|
||||||
ourDeliveryPkScript, _ = hex.DecodeString("76a914e8048c0fb75bdecc91ebfb99c174f4ece29ffbd488ac")
|
ourDeliveryPkScript, _ = hex.DecodeString("76a914e8048c0fb75bdecc91ebfb99c174f4ece29ffbd488ac")
|
||||||
@ -40,16 +40,16 @@ var (
|
|||||||
//funding request
|
//funding request
|
||||||
createChannel = CreateChannel{
|
createChannel = CreateChannel{
|
||||||
ChannelType: uint8(0),
|
ChannelType: uint8(0),
|
||||||
OurFundingAmount: btcutil.Amount(100000000),
|
FundingAmount: btcutil.Amount(100000000),
|
||||||
OurReserveAmount: btcutil.Amount(131072),
|
ReserveAmount: btcutil.Amount(131072),
|
||||||
OurMinFeePerKb: btcutil.Amount(20000),
|
MinFeePerKb: btcutil.Amount(20000),
|
||||||
MinTotalFundingAmount: btcutil.Amount(150000000),
|
MinTotalFundingAmount: btcutil.Amount(150000000),
|
||||||
LockTime: uint32(4320), //30 block-days
|
LockTime: uint32(4320), //30 block-days
|
||||||
FeePayer: uint8(0),
|
FeePayer: uint8(0),
|
||||||
OurRevocationHash: ourRevocationHash,
|
RevocationHash: ourRevocationHash,
|
||||||
OurPubkey: ourPubKey,
|
Pubkey: ourPubKey,
|
||||||
OurDeliveryPkScript: ourDeliveryPkScript,
|
DeliveryPkScript: ourDeliveryPkScript,
|
||||||
OurInputs: ourInputs,
|
Inputs: ourInputs,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user