Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/115.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何在Swift 4中将比特币从一个钱包发送到另一个钱包_Ios_Swift_Swift4_Bitcoin - Fatal编程技术网

Ios 如何在Swift 4中将比特币从一个钱包发送到另一个钱包

Ios 如何在Swift 4中将比特币从一个钱包发送到另一个钱包,ios,swift,swift4,bitcoin,Ios,Swift,Swift4,Bitcoin,我正在开发定制比特币钱包,我能够使用Yenom/BitcoinKit生成公钥/私钥。我需要将BTC发送到另一个我正在尝试使用的钱包。但我无法发送Btc。我该怎么做?我们可以使用比特币套件以外的其他库将Btc从一个钱包发送到另一个钱包吗 那么我如何用Swift将BTC从一个钱包转移到另一个钱包呢 建议 请检查以下链接 有一个函数名为sendToSomeAddress private func sendToSomeAddress(_ amount: Int64) { let toA

我正在开发定制比特币钱包,我能够使用Yenom/BitcoinKit生成公钥/私钥。我需要将BTC发送到另一个我正在尝试使用的钱包。但我无法发送Btc。我该怎么做?我们可以使用比特币套件以外的其他库将Btc从一个钱包发送到另一个钱包吗

那么我如何用Swift将BTC从一个钱包转移到另一个钱包呢 建议


请检查以下链接

有一个函数名为
sendToSomeAddress

private func sendToSomeAddress(_ amount: Int64) {
        let toAddress: Address = try! AddressFactory.create("bchtest:qpytf7xczxf2mxa3gd6s30rthpts0tmtgyw8ud2sy3")
        let changeAddress: Address = try! AppController.shared.wallet!.changeAddress()

        var utxos: [UnspentTransaction] = []
        for p in payments {
            let value = p.amount
            let lockScript = Script.buildPublicKeyHashOut(pubKeyHash: p.to.data)
            let txHash = Data(p.txid.reversed())
            let txIndex = UInt32(p.index)
            print(p.txid.hex, txIndex, lockScript.hex, value)

            let unspentOutput = TransactionOutput(value: value, lockingScript: lockScript)
            let unspentOutpoint = TransactionOutPoint(hash: txHash, index: txIndex)
            let utxo = UnspentTransaction(output: unspentOutput, outpoint: unspentOutpoint)
            utxos.append(utxo)
        }

        let unsignedTx = createUnsignedTx(toAddress: toAddress, amount: amount, changeAddress: changeAddress, utxos: utxos)
        let signedTx = signTx(unsignedTx: unsignedTx, keys: usedKeys())

        peerGroup?.sendTransaction(transaction: signedTx)
    }

我希望这会有所帮助

感谢Buddy@hardikdevios的回答。我将检查它并尝试实施它。如果这对我有效,我将接受你的回答Hello@Hardikdevios,它包含更改地址,你能告诉我它是做什么用的吗?我们为什么要换地址?