Skip to content

Commit

Permalink
Merge pull request #7 from chinaliuhan/main
Browse files Browse the repository at this point in the history
Fix that build() in NewTxBuild() cannot be called externally.
  • Loading branch information
hjguang2018 authored Aug 3, 2023
2 parents f475ef8 + 8fe3788 commit f34506b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion coins/bitcoin/basetx_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (build *TransactionBuilder) AddOutput(address string, amount int64) {
build.outputs = append(build.outputs, output)
}

func (build *TransactionBuilder) build() (string, error) {
func (build *TransactionBuilder) Build() (string, error) {
if len(build.inputs) == 0 || len(build.outputs) == 0 {
return "", errors.New("invalid inputs or outputs")
}
Expand Down
8 changes: 4 additions & 4 deletions coins/bitcoin/basetx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestSignTx(t *testing.T) {
txBuild := NewTxBuild(1, &chaincfg.TestNet3Params)
txBuild.AddInput("c44a7f98434e5e875a573339f77d36022c79c525771fa88c72fa53f3a55eeaf7", 1, "41f6ddee917e8ed190f003374064ace7b21ec405964a9861b4c4a9d6ff69f920", "", "mouQtmBWDS7JnT65Grj2tPzdSmGKJgRMhE", 1488430)
txBuild.AddOutput("mouQtmBWDS7JnT65Grj2tPzdSmGKJgRMhE", 1488200)
txHex, err := txBuild.build()
txHex, err := txBuild.Build()
if err != nil {
t.Fatal(err)
}
Expand All @@ -31,7 +31,7 @@ func TestSignTx(t *testing.T) {
txBuild.AddInput("ce69ca86b68708afc8484dacb7730006e7eff6d0c18b18a16a9e91abeefeb08a", 0, "41f6ddee917e8ed190f003374064ace7b21ec405964a9861b4c4a9d6ff69f920", "", "2NF33rckfiQTiE5Guk5ufUdwms8PgmtnEdc", 2000)
txBuild.AddOutput("2NF33rckfiQTiE5Guk5ufUdwms8PgmtnEdc", 900)
txBuild.AddOutput("2NF33rckfiQTiE5Guk5ufUdwms8PgmtnEdc", 850)
txHex, err = txBuild.build()
txHex, err = txBuild.Build()
if err != nil {
t.Fatal(err)
}
Expand All @@ -41,7 +41,7 @@ func TestSignTx(t *testing.T) {
txBuild = NewTxBuild(1, &chaincfg.TestNet3Params)
txBuild.AddInput("0bc66f18fd95ca00b6569471aa2dcd47fe45d3446fbaeec9ced228b00713fe8c", 0, "41f6ddee917e8ed190f003374064ace7b21ec405964a9861b4c4a9d6ff69f920", "", "tb1qtsq9c4fje6qsmheql8gajwtrrdrs38kdzeersc", 200000)
txBuild.AddOutput("tb1qtsq9c4fje6qsmheql8gajwtrrdrs38kdzeersc", 199700)
txHex, err = txBuild.build()
txHex, err = txBuild.Build()
if err != nil {
t.Fatal(err)
}
Expand All @@ -51,7 +51,7 @@ func TestSignTx(t *testing.T) {
txBuild = NewTxBuild(1, &chaincfg.TestNet3Params)
txBuild.AddInput("3cb62c77c5c3fc032100af4cae9eeb342829cbc5b49815f8db1bb8156314a784", 0, "41f6ddee917e8ed190f003374064ace7b21ec405964a9861b4c4a9d6ff69f920", "", "tb1pklh8lqax5l7m2ycypptv2emc4gata2dy28svnwcp9u32wlkenvsspcvhsr", 546)
txBuild.AddOutput("tb1pklh8lqax5l7m2ycypptv2emc4gata2dy28svnwcp9u32wlkenvsspcvhsr", 300)
txHex, err = txBuild.build()
txHex, err = txBuild.Build()
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit f34506b

Please sign in to comment.