Skip to content

Commit

Permalink
fixing up some line lengths and adding some nolinters
Browse files Browse the repository at this point in the history
  • Loading branch information
theflyingcodr committed May 14, 2021
1 parent c66d04d commit 4f8aae5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ linters-settings:
lll:
# max line length, lines longer will be reported. Default is 120.
# '\t' is counted as 1 character by default, and can be changed with the tab-width option
line-length: 120
line-length: 150
# tab width in spaces. Default to 1.
tab-width: 1
maligned:
Expand Down
10 changes: 7 additions & 3 deletions coinbase.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Here is a real example coinbase broken down...
| 00000000000000000000000000000000 ... Previous outpoint TXID
| ffffffff ............................ Previous outpoint index
|
| 43 .................................. Input coinbase count of bytes (4 block height + 12 (extra nonces) + Arbitrary data length)
| 43 .................................. Input coinbase count of bytes (4 block height + 12(extra nonces) + Arbitrary data length)
| |
| | 03 ................................ Bytes in height
| | | bfea07 .......................... Height: 518847
Expand Down Expand Up @@ -60,7 +60,8 @@ func BuildCoinbase(c1 []byte, c2 []byte, extraNonce1 string, extraNonce2 string)

// GetCoinbaseParts returns the two split coinbase parts from coinbase metadata.
// See https://arxiv.org/pdf/1703.06545.pdf section 2.2 for more info.
func GetCoinbaseParts(height uint32, coinbaseValue uint64, defaultWitnessCommitment string, coinbaseText string, walletAddress string, minerIDBytes []byte) (coinbase1 []byte, coinbase2 []byte, err error) {
func GetCoinbaseParts(height uint32, coinbaseValue uint64, defaultWitnessCommitment string, coinbaseText string,
walletAddress string, minerIDBytes []byte) (coinbase1 []byte, coinbase2 []byte, err error) {
coinbase1 = makeCoinbase1(height, coinbaseText)

ot, err := makeCoinbaseOutputTransactions(coinbaseValue, defaultWitnessCommitment, walletAddress, minerIDBytes)
Expand All @@ -73,6 +74,7 @@ func GetCoinbaseParts(height uint32, coinbaseValue uint64, defaultWitnessCommitm
return
}

//nolint:makezero
func makeCoinbaseOutputTransactions(coinbaseValue uint64, defaultWitnessCommitment string, wallet string, minerIDBytes []byte) ([]byte, error) {
o, err := bt.NewP2PKHOutputFromAddress(wallet, coinbaseValue)
if err != nil {
Expand Down Expand Up @@ -114,6 +116,7 @@ func makeCoinbaseOutputTransactions(coinbaseValue uint64, defaultWitnessCommitme
return buf, nil
}

//nolint:makezero
func makeCoinbase1(height uint32, coinbaseText string) []byte {
spaceForExtraNonce := 12

Expand Down Expand Up @@ -159,7 +162,8 @@ func makeCoinbase2(ot []byte) []byte {
// buf := make([]byte, 32) // 32 bytes - All bits are zero: Not a transaction hash reference
// buf = append(buf, []byte{0xff, 0xff, 0xff, 0xff}...) // 4 bytes - All bits are ones: 0xFFFFFFFF
// buf = append(buf, bt.VarInt(uint64(len(coinbaseData)))...) // Length of the coinbase data, from 2 to 100 bytes
// buf = append(buf, coinbaseData...) // Arbitrary data used for extra nonce and mining tags. In v2 blocks; must begin with block height
// buf = append(buf, coinbaseData...) // Arbitrary data used for extra nonce and mining tags.
// In v2 blocks; must begin with block height
// buf = append(buf, []byte{0xff, 0xff, 0xff, 0xff}...) // 4 bytes = Set to 0xFFFFFFFF
// return buf
// }
Expand Down

0 comments on commit 4f8aae5

Please sign in to comment.