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