txsort: Update package for BIP0069 acceptance.
BIPLI01 has been accepted as BIP0069, so update the README, comments, tests, and testdata files as such.
This commit is contained in:
parent
52bb44a147
commit
e0dbb5b535
9 changed files with 17 additions and 17 deletions
|
@ -7,9 +7,9 @@ txsort
|
|||
[![GoDoc](http://img.shields.io/badge/godoc-reference-blue.svg)]
|
||||
(http://godoc.org/github.com/btcsuite/btcutil/txsort)
|
||||
|
||||
Package txsort provides the transaction sorting according to BIPLI01.
|
||||
Package txsort provides the transaction sorting according to [BIP 69](https://github.com/bitcoin/bips/blob/master/bip-0069.mediawiki).
|
||||
|
||||
BIPLI01 defines a standard lexicographical sort order of transaction inputs and
|
||||
BIP 69 defines a standard lexicographical sort order of transaction inputs and
|
||||
outputs. This is useful to standardize transactions for faster multi-party
|
||||
agreement as well as preventing information leaks in a single-party use case.
|
||||
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
// license that can be found in the LICENSE file.
|
||||
|
||||
/*
|
||||
Package txsort provides the transaction sorting according to BIPLI01.
|
||||
Package txsort provides the transaction sorting according to BIP 69.
|
||||
|
||||
Overview
|
||||
|
||||
BIPLI01 defines a standard lexicographical sort order of transaction inputs and
|
||||
BIP 69 defines a standard lexicographical sort order of transaction inputs and
|
||||
outputs. This is useful to standardize transactions for faster multi-party
|
||||
agreement as well as preventing information leaks in a single-party use case.
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
// Use of this source code is governed by an ISC
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Provides functions for sorting tx inputs and outputs according to BIP LI01
|
||||
// (https://github.com/kristovatlas/rfc/blob/master/bips/bip-li01.mediawiki)
|
||||
// Provides functions for sorting tx inputs and outputs according to BIP 69
|
||||
// (https://github.com/bitcoin/bips/blob/master/bip-0069.mediawiki)
|
||||
|
||||
package txsort
|
||||
|
||||
|
@ -15,7 +15,7 @@ import (
|
|||
)
|
||||
|
||||
// InPlaceSort modifies the passed transaction inputs and outputs to be sorted
|
||||
// based on BIP LI01.
|
||||
// based on BIP 69.
|
||||
//
|
||||
// WARNING: This function must NOT be called with published transactions since
|
||||
// it will mutate the transaction if it's not already sorted. This can cause
|
||||
|
@ -32,7 +32,7 @@ func InPlaceSort(tx *wire.MsgTx) {
|
|||
}
|
||||
|
||||
// Sort returns a new transaction with the inputs and outputs sorted based on
|
||||
// BIP LI01. The passed transaction is not modified and the new transaction
|
||||
// BIP 69. The passed transaction is not modified and the new transaction
|
||||
// might have a different hash if any sorting was done.
|
||||
func Sort(tx *wire.MsgTx) *wire.MsgTx {
|
||||
txCopy := tx.Copy()
|
||||
|
@ -42,7 +42,7 @@ func Sort(tx *wire.MsgTx) *wire.MsgTx {
|
|||
}
|
||||
|
||||
// IsSorted checks whether tx has inputs and outputs sorted according to BIP
|
||||
// LI01.
|
||||
// 69.
|
||||
func IsSorted(tx *wire.MsgTx) bool {
|
||||
if !sort.IsSorted(sortableInputSlice(tx.TxIn)) {
|
||||
return false
|
||||
|
@ -58,7 +58,7 @@ type sortableOutputSlice []*wire.TxOut
|
|||
|
||||
// For SortableInputSlice and SortableOutputSlice, three functions are needed
|
||||
// to make it sortable with sort.Sort() -- Len, Less, and Swap
|
||||
// Len and Swap are trivial. Less is BIP LI01 specific.
|
||||
// Len and Swap are trivial. Less is BIP 69 specific.
|
||||
func (s sortableInputSlice) Len() int { return len(s) }
|
||||
func (s sortableOutputSlice) Len() int { return len(s) }
|
||||
func (s sortableOutputSlice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
||||
|
|
|
@ -25,36 +25,36 @@ func TestSort(t *testing.T) {
|
|||
sortedHash string
|
||||
}{
|
||||
{
|
||||
name: "first test case from BIPLI01 - sorts inputs only, based on hash",
|
||||
hexFile: "li01-1.hex",
|
||||
name: "first test case from BIP 69 - sorts inputs only, based on hash",
|
||||
hexFile: "bip69-1.hex",
|
||||
isSorted: false,
|
||||
unsortedHash: "0a6a357e2f7796444e02638749d9611c008b253fb55f5dc88b739b230ed0c4c3",
|
||||
sortedHash: "839503cb611a3e3734bd521c608f881be2293ff77b7384057ab994c794fce623",
|
||||
},
|
||||
{
|
||||
name: "second test case from BIPLI01 - already sorted",
|
||||
hexFile: "li01-2.hex",
|
||||
name: "second test case from BIP 69 - already sorted",
|
||||
hexFile: "bip69-2.hex",
|
||||
isSorted: true,
|
||||
unsortedHash: "28204cad1d7fc1d199e8ef4fa22f182de6258a3eaafe1bbe56ebdcacd3069a5f",
|
||||
sortedHash: "28204cad1d7fc1d199e8ef4fa22f182de6258a3eaafe1bbe56ebdcacd3069a5f",
|
||||
},
|
||||
{
|
||||
name: "block 100001 tx[1] - sorts outputs only, based on amount",
|
||||
hexFile: "li01-3.hex",
|
||||
hexFile: "bip69-3.hex",
|
||||
isSorted: false,
|
||||
unsortedHash: "fbde5d03b027d2b9ba4cf5d4fecab9a99864df2637b25ea4cbcb1796ff6550ca",
|
||||
sortedHash: "0a8c246c55f6b82f094d211f4f57167bf2ea4898741d218b09bdb2536fd8d13f",
|
||||
},
|
||||
{
|
||||
name: "block 100001 tx[2] - sorts both inputs and outputs",
|
||||
hexFile: "li01-4.hex",
|
||||
hexFile: "bip69-4.hex",
|
||||
isSorted: false,
|
||||
unsortedHash: "8131ffb0a2c945ecaf9b9063e59558784f9c3a74741ce6ae2a18d0571dac15bb",
|
||||
sortedHash: "a3196553b928b0b6154b002fa9a1ce875adabc486fedaaaf4c17430fd4486329",
|
||||
},
|
||||
{
|
||||
name: "block 100998 tx[6] - sorts outputs only, based on output script",
|
||||
hexFile: "li01-5.hex",
|
||||
hexFile: "bip69-5.hex",
|
||||
isSorted: false,
|
||||
unsortedHash: "ff85e8fc92e71bbc217e3ea9a3bacb86b435e52b6df0b089d67302c293a2b81d",
|
||||
sortedHash: "9a6c24746de024f77cac9b2138694f11101d1c66289261224ca52a25155a7c94",
|
||||
|
|
Loading…
Reference in a new issue